Home > Software engineering >  difference between `-- and -- after running npm list
difference between `-- and -- after running npm list

Time:07-01

Whilst addressing GitHub dependabot updates, I've been looking through the dependencies list created after running npm ls -a.

I (think I) understand the nesting involved: a pipe indicates that packages below are part of the dependencies list, and so on.

see image created from running npm ls -a > file.txt

What I don't understand is the difference between -- and `--.

After looking at it for the best part of an hour (embarassingly) my best guess is that `-- indicates the last package in a given nesting, whilst -- is an indication there are more packages.

It would be great if anybody could help clarify and enlighten me on what's getting output here.

CodePudding user response:

Yep, it just means "the last one at this level". Depending on your locale, npm draws a nice little Unicode box drawing "end hook" thing, or the approximation you were seeing:

/tmp/example > LC_ALL=en_US.UTF-8 npm ls -a
example@ /tmp/example
└─┬ [email protected]
  ├── [email protected]
  ├── [email protected]
  └─┬ [email protected]
    └── [email protected]

/tmp/example > LC_ALL=C npm ls -a
example@ /tmp/example
`-- [email protected]
   -- [email protected]
   -- [email protected]
  `-- [email protected]
    `-- [email protected]

If you don't want to change your locale, but do want npm ls to use the better-looking glyphs, you can pass --unicode.

  • Related