fix: better workspace range resolution error

This commit is contained in:
Zoltan Kochan
2020-07-10 01:16:05 +03:00
parent 7f88619492
commit 379cdcaf82
3 changed files with 9 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/npm-resolver": patch
---
When resolution from workspace fails, print the path to the project that has the unsatisfied dependency.

View File

@@ -208,7 +208,7 @@ function tryResolveFromWorkspace (
if (!resolvedFromLocal) {
throw new PnpmError(
'NO_MATCHING_VERSION_INSIDE_WORKSPACE',
`No matching version found for ${wantedDependency.alias}@${pref} inside the workspace`
`In ${path.relative(process.cwd(), opts.projectDir)}: No matching version found for ${wantedDependency.alias}@${pref} inside the workspace`
)
}
return resolvedFromLocal

View File

@@ -1495,10 +1495,11 @@ test('workspace protocol: resolution fails if there is no matching local package
storeDir,
})
const projectDir = '/home/istvan/src'
let err!: Error
try {
await resolve({ alias: 'is-positive', pref: 'workspace:^3.0.0' }, {
projectDir: '/home/istvan/src',
projectDir,
registry,
workspacePackages: {},
})
@@ -1508,7 +1509,7 @@ test('workspace protocol: resolution fails if there is no matching local package
t.ok(err)
t.equal(err['code'], 'ERR_PNPM_NO_MATCHING_VERSION_INSIDE_WORKSPACE')
t.equal(err.message, 'No matching version found for is-positive@^3.0.0 inside the workspace')
t.equal(err.message, `In ${path.relative(process.cwd(), projectDir)}: No matching version found for is-positive@^3.0.0 inside the workspace`)
t.end()
})