-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Running `npm ls --json --long --all` was broken for any project containing a missing dependency from the node_modules folder. This fixes it by avoiding trying to read the extra data required by the --long option in case a dependency is missing. Fixes: #2724 PR-URL: #3119 Credit: @ruyadorno Close: #3119 Reviewed-by: @wraithgar
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2489,6 +2489,48 @@ t.test('ls --json', (t) => { | |
}) | ||
}) | ||
|
||
t.test('missing deps --long', (t) => { | ||
config.long = true | ||
npm.prefix = t.testdir({ | ||
'package.json': JSON.stringify({ | ||
name: 'test-npm-ls', | ||
version: '1.0.0', | ||
dependencies: { | ||
foo: '^1.0.0', | ||
bar: '^1.0.0', | ||
lorem: '^1.0.0', | ||
ipsum: '^1.0.0', | ||
}, | ||
}), | ||
...simpleNmFixture, | ||
}) | ||
ls.exec([], (err) => { | ||
t.equal( | ||
redactCwd(err.message), | ||
'missing: ipsum@^1.0.0, required by [email protected]', | ||
'should log missing dep as error' | ||
) | ||
t.equal( | ||
err.code, | ||
'ELSPROBLEMS', | ||
'should have ELSPROBLEMS error code' | ||
) | ||
t.match( | ||
jsonParse(result), | ||
{ | ||
name: 'test-npm-ls', | ||
version: '1.0.0', | ||
problems: [ | ||
'missing: ipsum@^1.0.0, required by [email protected]', | ||
], | ||
}, | ||
'should output json containing problems info' | ||
) | ||
config.long = false | ||
t.end() | ||
}) | ||
}) | ||
|
||
t.test('with filter arg', (t) => { | ||
npm.prefix = t.testdir({ | ||
'package.json': JSON.stringify({ | ||
|