Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ const getJsonOutputItem = (node, { global, long }) => {
if (node.isRoot && hasPackageJson)
item.name = node.package.name || node.name

if (long) {
if (long && !node[_missing]) {
item.name = item[_name]
const { dependencies, ...packageInfo } = node.package
Object.assign(item, packageInfo)
Expand Down
42 changes: 42 additions & 0 deletions test/lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,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({
Expand Down