diff options
author | Ruy Adorno <ruyadorno@hotmail.com> | 2020-09-25 18:19:38 +0300 |
---|---|---|
committer | nlf <quitlahok@gmail.com> | 2020-09-29 21:43:49 +0300 |
commit | e225ddcf8d74a6b1cfb24ec49e37e3f5d06e5151 (patch) | |
tree | 4baeb91ef61eaa7b6e98a9b62e08a818589a4afc /tap-snapshots | |
parent | 2715220c9b5d3f325e65e95bae2b5af8a485a579 (diff) |
fix: npm ls <pkg> with depth cli config
Using the cli option --depth is currently not resulting in the expected
behavior of filtering depth level when running npm ls <pkg> - that's due
the special behavior of printing all results when using a filter arg.
This commit fixes it by adding support to limiting depth if a config
value is set by the user.
Fixes #1861
PR-URL: https://github.com/npm/cli/pull/1862
Credit: @ruyadorno
Close: #1862
Reviewed-by: @nlf
Diffstat (limited to 'tap-snapshots')
-rw-r--r-- | tap-snapshots/test-lib-ls.js-TAP.test.js | 20 | ||||
-rw-r--r-- | tap-snapshots/test-lib-utils-config.js-TAP.test.js | 21 |
2 files changed, 35 insertions, 6 deletions
diff --git a/tap-snapshots/test-lib-ls.js-TAP.test.js b/tap-snapshots/test-lib-ls.js-TAP.test.js index b5659a62e..6dc4d9a71 100644 --- a/tap-snapshots/test-lib-ls.js-TAP.test.js +++ b/tap-snapshots/test-lib-ls.js-TAP.test.js @@ -373,6 +373,26 @@ test-npm-ls@1.0.0 {CWD}/ls-ls-extraneous-deps ` +exports[`test/lib/ls.js TAP ls filter pkg arg using depth option > should list a in top-level only 1`] = ` +test-pkg-arg-filter-with-depth-opt@1.0.0 {CWD}/ls-ls-filter-pkg-arg-using-depth-option +\`-- a@1.0.0 + +` + +exports[`test/lib/ls.js TAP ls filter pkg arg using depth option > should print empty results msg 1`] = ` +test-pkg-arg-filter-with-depth-opt@1.0.0 {CWD}/ls-ls-filter-pkg-arg-using-depth-option +\`-- (empty) + +` + +exports[`test/lib/ls.js TAP ls filter pkg arg using depth option > should print expected result 1`] = ` +test-pkg-arg-filter-with-depth-opt@1.0.0 {CWD}/ls-ls-filter-pkg-arg-using-depth-option +\`-- b@1.0.0 + \`-- c@1.0.0 + \`-- d@1.0.0 + +` + exports[`test/lib/ls.js TAP ls filtering by child of missing dep > should print tree and not duplicate child of missing items 1`] = ` filter-by-child-of-missing-dep@1.0.0 {CWD}/ls-ls-filtering-by-child-of-missing-dep +-- b@1.0.0 extraneous diff --git a/tap-snapshots/test-lib-utils-config.js-TAP.test.js b/tap-snapshots/test-lib-utils-config.js-TAP.test.js index 771837959..90030fef7 100644 --- a/tap-snapshots/test-lib-utils-config.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-config.js-TAP.test.js @@ -32,7 +32,7 @@ Object { "cidr": null, "color": true, "commit-hooks": true, - "depth": 0, + "depth": null, "description": true, "dev": false, "dry-run": false, @@ -326,7 +326,10 @@ Object { "{Boolean TYPE}", ], "commit-hooks": "{Boolean TYPE}", - "depth": "{Number TYPE}", + "depth": Array [ + null, + "{Number TYPE}", + ], "description": "{Boolean TYPE}", "dev": "{Boolean TYPE}", "dry-run": "{Boolean TYPE}", @@ -541,7 +544,7 @@ Object { "cidr": null, "color": true, "commit-hooks": true, - "depth": 0, + "depth": null, "description": true, "dev": false, "dry-run": false, @@ -835,7 +838,10 @@ Object { "{Boolean TYPE}", ], "commit-hooks": "{Boolean TYPE}", - "depth": "{Number TYPE}", + "depth": Array [ + null, + "{Number TYPE}", + ], "description": "{Boolean TYPE}", "dev": "{Boolean TYPE}", "dry-run": "{Boolean TYPE}", @@ -1050,7 +1056,7 @@ Object { "cidr": null, "color": true, "commit-hooks": true, - "depth": 0, + "depth": null, "description": true, "dev": false, "dry-run": false, @@ -1344,7 +1350,10 @@ Object { "{Boolean TYPE}", ], "commit-hooks": "{Boolean TYPE}", - "depth": "{Number TYPE}", + "depth": Array [ + null, + "{Number TYPE}", + ], "description": "{Boolean TYPE}", "dev": "{Boolean TYPE}", "dry-run": "{Boolean TYPE}", |