Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9981211

Browse filesBrowse files
ruyadornonlf
authored andcommitted
fix: npm outdated parsing invalid specs
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 PR-URL: #1857 Credit: @ruyadorno Close: #1857 Reviewed-by: @nlf
1 parent 52114b7 commit 9981211
Copy full SHA for 9981211

File tree

Expand file treeCollapse file tree

2 files changed

+128
-73
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+128
-73
lines changed
Open diff view settings
Collapse file

‎lib/outdated.js‎

Copy file name to clipboardExpand all lines: lib/outdated.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ async function outdated_ (tree, deps, opts) {
138138
const packument = await getPackument(spec)
139139
const expected = edge.spec
140140
// if it's not a range, version, or tag, skip it
141-
/* istanbul ignore next */
142-
if (!npa(`${edge.name}@${edge.spec}`).registry) {
141+
try {
142+
if (!npa(`${edge.name}@${edge.spec}`).registry) {
143+
return null
144+
}
145+
} catch (err) {
143146
return null
144147
}
145148
const wanted = pickManifest(packument, expected, npm.flatOptions)
@@ -170,7 +173,7 @@ async function outdated_ (tree, deps, opts) {
170173
err.code === 'E403' ||
171174
err.code === 'E404')
172175
) {
173-
throw (err)
176+
throw err
174177
}
175178
}
176179
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.