diff --git a/lib/commands/ls.js b/lib/commands/ls.js index bc8beb007e809..9c46b21ff4cb1 100644 --- a/lib/commands/ls.js +++ b/lib/commands/ls.js @@ -69,6 +69,7 @@ class LS extends ArboristWorkspaceCmd { ...this.npm.flatOptions, legacyPeerDeps: false, path, + forceActual: long && !json && !parseable && !packageLockOnly, }) const tree = await this.initTree({ arb, args, packageLockOnly }) @@ -339,7 +340,7 @@ const getHumanOutputItem = (node, { args, chalk, global, long }) => { ) + (isGitNode(node) ? ` (${node.resolved})` : '') + (node.isLink ? ` -> ${relativePrefix}${targetLocation}` : '') + - (long ? `\n${node.package.description || ''}` : '') + (long && !node[_missing] ? `\n${node.package.description || ''}` : '') return augmentItemWithIncludeMetadata(node, { label, nodes: [] }) } diff --git a/tap-snapshots/test/lib/commands/ls.js.test.cjs b/tap-snapshots/test/lib/commands/ls.js.test.cjs index fc7fbdf8a906f..26bcbcf4b68f5 100644 --- a/tap-snapshots/test/lib/commands/ls.js.test.cjs +++ b/tap-snapshots/test/lib/commands/ls.js.test.cjs @@ -18,6 +18,32 @@ Array [ ] ` +exports[`test/lib/commands/ls.js TAP ignore missing optional deps --long human output > ls --long result 1`] = ` +test-npm-ls-ignore-missing-optional@1.2.3 +| {CWD}/prefix +| ++-- UNMET OPTIONAL DEPENDENCY optional-missing@1 ++-- optional-ok@1.2.3 +| ++-- optional-wrong@3.2.1 invalid: "1" from the root project +| ++-- UNMET DEPENDENCY peer-missing@1 ++-- peer-ok@1.2.3 +| ++-- UNMET OPTIONAL DEPENDENCY peer-optional-missing@1 ++-- peer-optional-ok@1.2.3 extraneous +| ++-- peer-optional-wrong@3.2.1 invalid: "1" from the root project extraneous +| ++-- peer-wrong@3.2.1 invalid: "1" from the root project +| ++-- UNMET DEPENDENCY prod-missing@1 ++-- prod-ok@1.2.3 +| +\`-- prod-wrong@3.2.1 invalid: "1" from the root project + +` + exports[`test/lib/commands/ls.js TAP ignore missing optional deps --parseable > ls --parseable result 1`] = ` {CWD}/prefix {CWD}/prefix/node_modules/optional-ok diff --git a/test/lib/commands/ls.js b/test/lib/commands/ls.js index c876af9e83ddf..f84212ea68900 100644 --- a/test/lib/commands/ls.js +++ b/test/lib/commands/ls.js @@ -2663,6 +2663,11 @@ t.test('ignore missing optional deps', async t => { const result = await mock(t) t.matchSnapshot(result, 'ls result') }) + + t.test('--long human output', async t => { + const result = await mock(t, { long: true }) + t.matchSnapshot(result, 'ls --long result') + }) }) t.test('ls --json', async t => {