Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ls: show relative paths from root, not absolute #3272

Merged
merged 1 commit into from May 24, 2021

Commits on May 24, 2021

  1. fix(ls): show relative paths from root

    Change the output in `npm ls` for symlink dependencies (including
    workspaces) to show the relative path from the project root, rather than
    the absolute path of the link target.
    
    This makes the output much less noisy and more ergonomic when many
    workspaces and link dependencies are in use, especially when paths are
    long.
    
    It is arguable that this output might be slightly misleading, since the
    _actual_ workspace symlink from `${root}/node_modules/b` to
    `${root}/packages/b` has a link value of `../packages/b`, not just
    `packages/b`.  (Or on Windows, always the full absolute path, because
    junctions.)  Thus, `npm ls b` will not show the same output as `ls -l
    node_modules/b`.
    
    However, `npm ls` shows the logical tree, not the physical tree, so
    presenting the user with a path that they can use and interpret is more
    important than presenting them with the strictly accurate details of
    their filesystem.
    
    PR-URL: #3272
    Credit: @isaacs
    Close: #3272
    Reviewed-by: @darcyclarke
    isaacs authored and wraithgar committed May 24, 2021
    Copy the full SHA
    83590d4 View commit details
    Browse the repository at this point in the history