Skip to content

Commit

Permalink
fix: npm outdated parsing invalid specs
Browse files Browse the repository at this point in the history
This commit fixes a problem in which npm outdated was breaking when
trying to read an invalid semver range spec defined for a given
installed dep by performing the `npm-package-arg` parsing within a
try/catch block instead of expecting to read properties from the
returned instance.

Also, adds the missing test for that specific line of code.

Fixes #1703
  • Loading branch information
ruyadorno committed Sep 29, 2020
1 parent 9bc6966 commit 84b5f6f
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 73 deletions.
9 changes: 6 additions & 3 deletions lib/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ async function outdated_ (tree, deps, opts) {
const packument = await getPackument(spec)
const expected = edge.spec
// if it's not a range, version, or tag, skip it
/* istanbul ignore next */
if (!npa(`${edge.name}@${edge.spec}`).registry) {
try {
if (!npa(`${edge.name}@${edge.spec}`).registry) {
return null
}
} catch (err) {
return null
}
const wanted = pickManifest(packument, expected, npm.flatOptions)
Expand Down Expand Up @@ -170,7 +173,7 @@ async function outdated_ (tree, deps, opts) {
err.code === 'E403' ||
err.code === 'E404')
) {
throw (err)
throw err
}
}
}
Expand Down
Loading

0 comments on commit 84b5f6f

Please sign in to comment.