Skip to content

Commit 4c534ed

Browse files
committed
fixup! ls: show relative paths from root, not absolute
1 parent 7d0671b commit 4c534ed

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

lib/ls.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const { resolve, relative } = require('path')
1+
const { resolve, relative, sep } = require('path')
2+
const relativePrefix = `.${sep}`
23
const { EOL } = require('os')
34

45
const archy = require('archy')
@@ -324,7 +325,7 @@ const getHumanOutputItem = (node, { args, color, global, long }) => {
324325
: ''
325326
) +
326327
(isGitNode(node) ? ` (${node.resolved})` : '') +
327-
(node.isLink ? ` -> ${targetLocation}` : '') +
328+
(node.isLink ? ` -> ${relativePrefix}${targetLocation}` : '') +
328329
(long ? `${EOL}${node.package.description || ''}` : '')
329330

330331
return augmentItemWithIncludeMetadata(node, { label, nodes: [] })

tap-snapshots/test/lib/ls.js.test.cjs

+23-23
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ [email protected] {CWD}/tap-testdir-ls-ls---dev
7070

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

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

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

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

496496
exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should filter using workspace config 1`] = `
497497
[email protected] {CWD}/tap-testdir-ls-ls-loading-a-tree-containing-workspaces
498-
498+
\`-- [email protected] -> ./a
499499
500-
500+
\`-- [email protected] -> ./d
501501
502502
503503
504504
`
505505

506506
exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should list --all workspaces properly 1`] = `
507507
[email protected] {CWD}/tap-testdir-ls-ls-loading-a-tree-containing-workspaces
508-
508+
509509
510-
| \`-- [email protected] deduped -> d
511-
512-
510+
| \`-- [email protected] deduped -> ./d
511+
512+
513513
514514
515-
+-- [email protected] -> group/e
516-
\`-- [email protected] -> group/f
515+
+-- [email protected] -> ./group/e
516+
\`-- [email protected] -> ./group/f
517517
518518
`
519519

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

531531
`
532532

533533
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`] = `
534534
[email protected] {CWD}/tap-testdir-ls-ls-loading-a-tree-containing-workspaces
535-
535+
\`-- [email protected] -> ./d
536536
537537
538538
@@ -567,8 +567,8 @@ [email protected] {CWD}/tap-testdir-ls-ls-no-args
567567
exports[`test/lib/ls.js TAP ls print deduped symlinks > should output tree containing linked deps 1`] = `
568568
[email protected] {CWD}/tap-testdir-ls-ls-print-deduped-symlinks
569569
570-
| \`-- [email protected] deduped -> b
571-
570+
| \`-- [email protected] deduped -> ./b
571+
\`-- [email protected] -> ./b
572572
573573
`
574574

0 commit comments

Comments
 (0)