Skip to content

Commit

Permalink
deps: path-scurry@1.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed May 17, 2023
1 parent d93f70c commit 53ecb84
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 17 deletions.
49 changes: 45 additions & 4 deletions node_modules/path-scurry/dist/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class ChildrenCache extends lru_cache_1.LRUCache {
}
}
exports.ChildrenCache = ChildrenCache;
const setAsCwd = Symbol('PathScurry setAsCwd');
/**
* Path objects are sort of like a super-powered
* {@link https://nodejs.org/docs/latest/api/fs.html#class-fsdirent fs.Dirent}
Expand Down Expand Up @@ -291,6 +292,16 @@ class PathBase {
#children;
#linkTarget;
#realpath;
/**
* This property is for compatibility with the Dirent class as of
* Node v20, where Dirent['path'] refers to the path of the directory
* that was passed to readdir. So, somewhat counterintuitively, this
* property refers to the *parent* path, not the path object itself.
* For root entries, it's the path to the entry itself.
*/
get path() {
return (this.parent || this).fullpath();
}
/**
* Do not create new Path objects directly. They should always be accessed
* via the PathScurry class or other methods on the Path class.
Expand Down Expand Up @@ -438,8 +449,7 @@ class PathBase {
return (this.#relative = this.name);
}
const pv = p.relative();
const rp = pv + (!pv || !p.parent ? '' : this.sep) + name;
return (this.#relative = rp);
return pv + (!pv || !p.parent ? '' : this.sep) + name;
}
/**
* The relative path from the cwd, using / as the path separator.
Expand All @@ -458,8 +468,7 @@ class PathBase {
return (this.#relativePosix = this.fullpathPosix());
}
const pv = p.relativePosix();
const rp = pv + (!pv || !p.parent ? '' : '/') + name;
return (this.#relativePosix = rp);
return pv + (!pv || !p.parent ? '' : '/') + name;
}
/**
* The fully resolved path string for this Path entry
Expand Down Expand Up @@ -1111,6 +1120,33 @@ class PathBase {
this.#markENOREALPATH();
}
}
/**
* Internal method to mark this Path object as the scurry cwd,
* called by {@link PathScurry#chdir}
*
* @internal
*/
[setAsCwd](oldCwd) {
if (oldCwd === this)
return;
const changed = new Set([]);
let rp = [];
let p = this;
while (p && p.parent) {
changed.add(p);
p.#relative = rp.join(this.sep);
p.#relativePosix = rp.join('/');
p = p.parent;
rp.push('..');
}
// now un-memoize parents of old cwd
p = oldCwd;
while (p && p.parent && !changed.has(p)) {
p.#relative = undefined;
p.#relativePosix = undefined;
p = p.parent;
}
}
}
exports.PathBase = PathBase;
/**
Expand Down Expand Up @@ -1838,6 +1874,11 @@ class PathScurryBase {
process();
return results;
}
chdir(path = this.cwd) {
const oldCwd = this.cwd;
this.cwd = typeof path === 'string' ? this.cwd.resolve(path) : path;
this.cwd[setAsCwd](oldCwd);
}
}
exports.PathScurryBase = PathScurryBase;
/**
Expand Down
49 changes: 45 additions & 4 deletions node_modules/path-scurry/dist/mjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export class ChildrenCache extends LRUCache {
});
}
}
const setAsCwd = Symbol('PathScurry setAsCwd');
/**
* Path objects are sort of like a super-powered
* {@link https://nodejs.org/docs/latest/api/fs.html#class-fsdirent fs.Dirent}
Expand Down Expand Up @@ -263,6 +264,16 @@ export class PathBase {
#children;
#linkTarget;
#realpath;
/**
* This property is for compatibility with the Dirent class as of
* Node v20, where Dirent['path'] refers to the path of the directory
* that was passed to readdir. So, somewhat counterintuitively, this
* property refers to the *parent* path, not the path object itself.
* For root entries, it's the path to the entry itself.
*/
get path() {
return (this.parent || this).fullpath();
}
/**
* Do not create new Path objects directly. They should always be accessed
* via the PathScurry class or other methods on the Path class.
Expand Down Expand Up @@ -410,8 +421,7 @@ export class PathBase {
return (this.#relative = this.name);
}
const pv = p.relative();
const rp = pv + (!pv || !p.parent ? '' : this.sep) + name;
return (this.#relative = rp);
return pv + (!pv || !p.parent ? '' : this.sep) + name;
}
/**
* The relative path from the cwd, using / as the path separator.
Expand All @@ -430,8 +440,7 @@ export class PathBase {
return (this.#relativePosix = this.fullpathPosix());
}
const pv = p.relativePosix();
const rp = pv + (!pv || !p.parent ? '' : '/') + name;
return (this.#relativePosix = rp);
return pv + (!pv || !p.parent ? '' : '/') + name;
}
/**
* The fully resolved path string for this Path entry
Expand Down Expand Up @@ -1083,6 +1092,33 @@ export class PathBase {
this.#markENOREALPATH();
}
}
/**
* Internal method to mark this Path object as the scurry cwd,
* called by {@link PathScurry#chdir}
*
* @internal
*/
[setAsCwd](oldCwd) {
if (oldCwd === this)
return;
const changed = new Set([]);
let rp = [];
let p = this;
while (p && p.parent) {
changed.add(p);
p.#relative = rp.join(this.sep);
p.#relativePosix = rp.join('/');
p = p.parent;
rp.push('..');
}
// now un-memoize parents of old cwd
p = oldCwd;
while (p && p.parent && !changed.has(p)) {
p.#relative = undefined;
p.#relativePosix = undefined;
p = p.parent;
}
}
}
/**
* Path class used on win32 systems
Expand Down Expand Up @@ -1807,6 +1843,11 @@ export class PathScurryBase {
process();
return results;
}
chdir(path = this.cwd) {
const oldCwd = this.cwd;
this.cwd = typeof path === 'string' ? this.cwd.resolve(path) : path;
this.cwd[setAsCwd](oldCwd);
}
}
/**
* Windows implementation of {@link PathScurryBase}
Expand Down
8 changes: 4 additions & 4 deletions node_modules/path-scurry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "path-scurry",
"version": "1.7.0",
"version": "1.9.1",
"description": "walk paths fast and efficiently",
"author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me)",
"main": "./dist/cjs/index.js",
Expand Down Expand Up @@ -58,7 +58,7 @@
},
"devDependencies": {
"@nodelib/fs.walk": "^1.2.8",
"@types/node": "^18.11.18",
"@types/node": "^20.1.4",
"@types/tap": "^15.0.7",
"c8": "^7.12.0",
"eslint-config-prettier": "^8.6.0",
Expand All @@ -81,7 +81,7 @@
"url": "git+https://github.com/isaacs/path-walker"
},
"dependencies": {
"lru-cache": "^9.0.0",
"minipass": "^5.0.0"
"lru-cache": "^9.1.1",
"minipass": "^5.0.0 || ^6.0.0"
}
}
10 changes: 5 additions & 5 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -10269,13 +10269,13 @@
"dev": true
},
"node_modules/path-scurry": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.7.0.tgz",
"integrity": "sha512-UkZUeDjczjYRE495+9thsgcVgsaCPkaw80slmfVFgllxY+IO8ubTsOpFVjDPROBqJdHfVPUFRHPBV/WciOVfWg==",
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.9.1.tgz",
"integrity": "sha512-UgmoiySyjFxP6tscZDgWGEAgsW5ok8W3F5CJDnnH2pozwSTGE6eH7vwTotMwATWA2r5xqdkKdxYPkwlJjAI/3g==",
"inBundle": true,
"dependencies": {
"lru-cache": "^9.0.0",
"minipass": "^5.0.0"
"lru-cache": "^9.1.1",
"minipass": "^5.0.0 || ^6.0.0"
},
"engines": {
"node": ">=16 || 14 >=14.17"
Expand Down

0 comments on commit 53ecb84

Please sign in to comment.