Skip to content

Commit

Permalink
fixup! ls: show relative paths from root, not absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed May 24, 2021
1 parent 26b07db commit 32acbb3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
5 changes: 3 additions & 2 deletions lib/ls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { resolve, relative } = require('path')
const { resolve, relative, sep } = require('path')
const relativePrefix = `.${sep}`
const { EOL } = require('os')

const archy = require('archy')
Expand Down Expand Up @@ -324,7 +325,7 @@ const getHumanOutputItem = (node, { args, color, global, long }) => {
: ''
) +
(isGitNode(node) ? ` (${node.resolved})` : '') +
(node.isLink ? ` -> ${targetLocation}` : '') +
(node.isLink ? ` -> ${relativePrefix}${targetLocation}` : '') +
(long ? `${EOL}${node.package.description || ''}` : '')

return augmentItemWithIncludeMetadata(node, { label, nodes: [] })
Expand Down
46 changes: 23 additions & 23 deletions tap-snapshots/test/lib/ls.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ [email protected] {CWD}/tap-testdir-ls-ls---dev

exports[`test/lib/ls.js TAP ls --link > should output tree containing linked deps 1`] = `
[email protected] {CWD}/tap-testdir-ls-ls---link
\`-- [email protected] -> linked-dep
\`-- [email protected] -> ./linked-dep
`

Expand Down Expand Up @@ -480,59 +480,59 @@ exports[`test/lib/ls.js TAP ls json read problems > should print empty result 1`

exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should filter by parent folder workspace config 1`] = `
[email protected] {CWD}/tap-testdir-ls-ls-loading-a-tree-containing-workspaces
+-- [email protected] -> group/e
\`-- [email protected] -> group/f
+-- [email protected] -> ./group/e
\`-- [email protected] -> ./group/f
`

exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should filter single workspace 1`] = `
[email protected] {CWD}/tap-testdir-ls-ls-loading-a-tree-containing-workspaces
+-- [email protected] -> a
| \`-- [email protected] deduped -> d
\`-- [email protected] -> d
+-- [email protected] -> ./a
| \`-- [email protected] deduped -> ./d
\`-- [email protected] -> ./d
`

exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should filter using workspace config 1`] = `
[email protected] {CWD}/tap-testdir-ls-ls-loading-a-tree-containing-workspaces
\`-- [email protected] -> a
\`-- [email protected] -> ./a
+-- [email protected]
\`-- [email protected] -> d
\`-- [email protected] -> ./d
\`-- [email protected]
\`-- [email protected]
`

exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should list --all workspaces properly 1`] = `
[email protected] {CWD}/tap-testdir-ls-ls-loading-a-tree-containing-workspaces
+-- [email protected] -> a
+-- [email protected] -> ./a
| +-- [email protected]
| \`-- [email protected] deduped -> d
+-- [email protected] -> b
+-- [email protected] -> d
| \`-- [email protected] deduped -> ./d
+-- [email protected] -> ./b
+-- [email protected] -> ./d
| \`-- [email protected]
| \`-- [email protected]
+-- [email protected] -> group/e
\`-- [email protected] -> group/f
+-- [email protected] -> ./group/e
\`-- [email protected] -> ./group/f
`

exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should list workspaces properly with default configs 1`] = `
[[email protected] {CWD}/tap-testdir-ls-ls-loading-a-tree-containing-workspaces
[0m+-- [[email protected][39m -> a[0m
[0m+-- [[email protected][39m -> ./a[0m
| +-- [email protected]
[0m| \`-- [email protected] [90mdeduped[39m -> d[0m
[0m+-- [[email protected][39m -> b[0m
[0m+-- [[email protected][39m -> d[0m
[0m| \`-- [email protected] [90mdeduped[39m -> ./d[0m
[0m+-- [[email protected][39m -> ./b[0m
[0m+-- [[email protected][39m -> ./d[0m
| \`-- [email protected]
[0m+-- [[email protected][39m -> group/e[0m
[0m\`-- [[email protected][39m -> group/f[0m
[0m+-- [[email protected][39m -> ./group/e[0m
[0m\`-- [[email protected][39m -> ./group/f[0m

`

exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should print all tree and filter by dep within only the ws subtree 1`] = `
[email protected] {CWD}/tap-testdir-ls-ls-loading-a-tree-containing-workspaces
\`-- [email protected] -> d
\`-- [email protected] -> ./d
\`-- [email protected]
\`-- [email protected]
Expand Down Expand Up @@ -567,8 +567,8 @@ [email protected] {CWD}/tap-testdir-ls-ls-no-args
exports[`test/lib/ls.js TAP ls print deduped symlinks > should output tree containing linked deps 1`] = `
[email protected] {CWD}/tap-testdir-ls-ls-print-deduped-symlinks
+-- [email protected]
| \`-- [email protected] deduped -> b
\`-- [email protected] -> b
| \`-- [email protected] deduped -> ./b
\`-- [email protected] -> ./b
`

Expand Down

0 comments on commit 32acbb3

Please sign in to comment.