Skip to content
This repository was archived by the owner on Jul 28, 2021. It is now read-only.

Commit 2d7bec4

Browse files
committed
feat(fs): add directory support to fs ops
1 parent 3bc6210 commit 2d7bec4

File tree

6 files changed

+249
-163
lines changed

6 files changed

+249
-163
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ but now it's a package manager runtime!
5353
* [x] add support for auth and .npmrc
5454
* [x] implement fs.readdir* (needed for webpack)
5555
* [x] use spawn-wrap to support child_process calls
56-
* [ ] warn if installing a package that requires run-scripts
57-
* [ ] warn if installing something that requires bin/man linking
58-
* [ ] add support for removing package tarballs from cache
56+
* [x] add directory support to fs ops
5957
* [ ] add fallback where "incompatible" packages get dumped into node_modules (and tagged a such in `package-map.json`)
6058
* [ ] add support for node-gyp build caching to make native packages compatible
6159
* [ ] add support for bin/man linking
60+
* [ ] warn if installing a package that requires run-scripts
61+
* [ ] warn if installing something that requires bin/man linking
6262
* [ ] benchmark wubwub?
6363
* [ ] write tests for fs overrides
6464
* [ ] optimize fs and module load operations (need to analyze)

lib/ensure-package.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,15 @@ class CacacheUnpacker extends tar.Parse {
182182
algorithms: ['sha256']
183183
})
184184
cacacheMemo.put.byDigest(this.cache, integrity, data)
185-
this.metadata.files[entry.path] = integrity.toString()
185+
entry.path.split(/[/\\]+/g).reduce((acc, next, i, sections) => {
186+
if (next === '.') { return acc }
187+
if (i === sections.length - 1) {
188+
acc[next] = integrity.toString()
189+
} else {
190+
acc[next] = acc[next] || {}
191+
}
192+
return acc[next]
193+
}, this.metadata.files)
186194
this[UNPEND]()
187195
} catch (err) {
188196
this[ONERROR](err, entry)

0 commit comments

Comments
 (0)