Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
fix(manifest): ETARGET when no packages match
Browse files Browse the repository at this point in the history
Fixes: #34

This brings pick-manifest more in line with npm on this matter.
  • Loading branch information
zkat committed Mar 6, 2017
1 parent fa3c430 commit ea2127d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/registry/pick-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function pickManifest (metadata, spec, opts) {
var err
return BB.fromNode(cb => {
if (!versions.length) {
err = new Error('Package has no valid versions.')
err = new Error(`No valid versions available for ${metadata.name}`)
err.code = 'ENOVERSIONS'
err.name = metadata.name
err.spec = spec
Expand Down Expand Up @@ -56,8 +56,8 @@ function pickManifest (metadata, spec, opts) {

var manifest = target && metadata.versions[target]
if (!manifest) {
err = new Error('No matching versions')
err.code = 'ENOENT'
err = new Error(`No matching version found for ${spec.name}@${spec.spec}`)
err.code = 'ETARGET'
err.name = metadata.name
err.spec = spec
err.versions = versions
Expand Down
4 changes: 2 additions & 2 deletions test/registry.pick-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test('skips any invalid version keys', t => {
() => { throw new Error('expected a failure') },
err => {
t.ok(err, 'got an error')
t.equal(err.code, 'ENOENT', 'no matching specs')
t.equal(err.code, 'ETARGET', 'no matching specs')
}
)
)
Expand All @@ -140,7 +140,7 @@ test('ENOENT if range does not match anything', t => {
() => { throw new Error('expected a failure') },
err => {
t.ok(err, 'got an error')
t.equal(err.code, 'ENOENT', 'useful error code returned.')
t.equal(err.code, 'ETARGET', 'useful error code returned.')
}
)
})
Expand Down

0 comments on commit ea2127d

Please sign in to comment.