diff options
author | Samuel Marks <samuelmarks@gmail.com> | 2017-07-29 02:29:45 +0300 |
---|---|---|
committer | Kat Marchán <kzm@sykosomatic.org> | 2017-07-29 02:29:45 +0300 |
commit | c3d1d3ba82aa41dfb2bd135e6cdc59f8d33cd9fb (patch) | |
tree | 77a3ea5d098bbd71bb5a381bf995dadfe3d3b53e /lib | |
parent | 44b98b9ddcfcccf68967fdf106fca52bf0c3da4b (diff) |
deps: catch more `npa` parse failures (#17816)
Fixes: #17283
PR-URL: https://github.com/npm/npm/pull/17816
Credit: @SamuelMarks
Reviewed-By: @zkat
Diffstat (limited to 'lib')
-rw-r--r-- | lib/install/deps.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/install/deps.js b/lib/install/deps.js index d7a2c27c1..8ba6cdc64 100644 --- a/lib/install/deps.js +++ b/lib/install/deps.js @@ -197,18 +197,31 @@ function matchingDep (tree, name) { exports.getAllMetadata = function (args, tree, where, next) { asyncMap(args, function (arg, done) { - var spec = npa(arg) + let spec + try { + spec = npa(arg) + } catch (e) { + return done(e) + } if (spec.type !== 'file' && spec.type !== 'directory' && (spec.name == null || spec.rawSpec === '')) { return fs.stat(path.join(arg, 'package.json'), (err) => { if (err) { var version = matchingDep(tree, spec.name) if (version) { - return fetchPackageMetadata(npa.resolve(spec.name, version), where, done) + try { + return fetchPackageMetadata(npa.resolve(spec.name, version), where, done) + } catch (e) { + return done(e) + } } else { return fetchPackageMetadata(spec, where, done) } } else { - return fetchPackageMetadata(npa('file:' + arg), where, done) + try { + return fetchPackageMetadata(npa('file:' + arg), where, done) + } catch (e) { + return done(e) + } } }) } else { |