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

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

Build:
Build:
LAST BUILD BRANCH: dependabot/npm_and_yarn/hosted-git-info-2.8.9
DEFAULT BRANCH: master
Repo Added 31 May 2015 08:51PM UTC
Files 2
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

LAST BUILD ON BRANCH isaacs/less-lstat
branch: isaacs/less-lstat
CHANGE BRANCH
x
Reset
  • isaacs/less-lstat
  • dependabot/npm_and_yarn/handlebars-4.5.3
  • dependabot/npm_and_yarn/handlebars-4.7.6
  • dependabot/npm_and_yarn/handlebars-4.7.7
  • dependabot/npm_and_yarn/hosted-git-info-2.8.9
  • dependabot/npm_and_yarn/lodash-4.17.15
  • dependabot/npm_and_yarn/lodash-4.17.19
  • dependabot/npm_and_yarn/lodash-4.17.21
  • dependabot/npm_and_yarn/y18n-3.2.2
  • dependabot/npm_and_yarn/yargs-parser-13.1.2
  • isaacs/promisify
  • isaacs/read-depinfo
  • master
  • trav
  • v5.1.0
  • v5.1.1
  • v5.1.2
  • v5.1.3
  • v5.1.4
  • v5.1.6
  • v5.2.0
  • v5.2.1
  • v5.2.2
  • v5.3.0
  • v5.3.1

pending completion
74

Pull #20

travis-ci

web-flow
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.
Pull Request #20: Use custom cachable fs.realpath implementation

45 of 45 branches covered (100.0%)

75 of 75 new or added lines in 2 files covered. (100.0%)

123 of 123 relevant lines covered (100.0%)

268.27 hits per line

Relevant lines Covered
Build:
Build:
123 RELEVANT LINES 123 COVERED LINES
268.27 HITS PER LINE
Source Files on isaacs/less-lstat
  • List 0
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
74 isaacs/less-lstat 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 ... Pull #20 11 Jun 2019 06:57AM UTC web-flow travis-ci pending completion  
73 isaacs/less-lstat 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 ... push 11 Jun 2019 06:56AM UTC isaacs travis-ci pending completion  
70 isaacs/less-lstat 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 ... Pull #20 10 Jun 2019 11:19PM UTC web-flow travis-ci pending completion  
69 isaacs/less-lstat 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 ... push 10 Jun 2019 11:19PM UTC isaacs travis-ci pending completion  
68 isaacs/less-lstat 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 ... Pull #20 10 Jun 2019 11:14PM UTC web-flow travis-ci pending completion  
67 isaacs/less-lstat 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 ... push 10 Jun 2019 11:13PM UTC isaacs travis-ci pending completion  
See All Builds (75)
  • Repo on GitHub
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

© 2025 Coveralls, Inc