• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

npm / read-package-tree / 69
100%
master: 100%

Build:
Build:
LAST BUILD BRANCH: dependabot/npm_and_yarn/hosted-git-info-2.8.9
DEFAULT BRANCH: master
Ran 10 Jun 2019 11:19PM UTC
Jobs 3
Files 2
Run time 9s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
69

push

travis-ci

isaacs
Use custom cachable fs.realpath implementation

In this use case, we don't care much about a lot of the stuff that
fs.realpath can (and should!) do.  The only thing that's relevant to
reading a package tree is whether package folders are symbolic links,
and if so, where they point.

Additionally, we don't need to re-start the fs.lstat party every time we
walk to a new directory.  While it makes sense for fs.realpath to do
this in the general case, it's not required when reading a package tree,
and results in a geometric explosion of lstat syscalls.  For example, if
a project is in /Users/hyooman/projects/company/website, and it has 1000
dependencies in node_modules, then a whopping 6,000 lstat calls will be
made just to repeatedly verify that
/Users/hyooman/projects/company/website/node_modules has not moved!

In this implementation, every realpath call is cached, as is every
lstat.  Additionally, process.cwd() is assumed to be "real enough", and
added to the cache initially, which means almost never having to walk
all the way up to the root directory.

In the npm cli project, this drops the lstat count from 14885 to 3054
for a single call to read-package-tree on my system.  Larger projects,
or projects deeper in a folder tree, will have even larger reductions.

This does not account, itself, for a particularly large speed-up, since
lstat calls do tend to be fairly fast, and the repetitiveness means that
there are a lot of hits in the file system's stat cache.  But it does
make read-package-tree 10-30% faster in common use cases.

45 of 45 branches covered (100.0%)

123 of 123 relevant lines covered (100.0%)

268.27 hits per line

Jobs
ID Job ID Ran Files Coverage
1 69.1 10 Jun 2019 11:19PM UTC 0
100.0
Travis Job 69.1
2 69.2 10 Jun 2019 11:19PM UTC 0
100.0
Travis Job 69.2
3 69.3 10 Jun 2019 11:19PM UTC 0
100.0
Travis Job 69.3
Source Files on build 69
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #69
  • c87d769f on github
  • Prev Build on isaacs/less-lstat (#67)
  • Next Build on isaacs/less-lstat (#73)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc