Skip to content

Commit 53ecb84

Browse files
committed
deps: path-scurry@1.9.1
1 parent d93f70c commit 53ecb84

File tree

4 files changed

+99
-17
lines changed

4 files changed

+99
-17
lines changed

node_modules/path-scurry/dist/cjs/index.js

+45-4
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class ChildrenCache extends lru_cache_1.LRUCache {
159159
}
160160
}
161161
exports.ChildrenCache = ChildrenCache;
162+
const setAsCwd = Symbol('PathScurry setAsCwd');
162163
/**
163164
* Path objects are sort of like a super-powered
164165
* {@link https://nodejs.org/docs/latest/api/fs.html#class-fsdirent fs.Dirent}
@@ -291,6 +292,16 @@ class PathBase {
291292
#children;
292293
#linkTarget;
293294
#realpath;
295+
/**
296+
* This property is for compatibility with the Dirent class as of
297+
* Node v20, where Dirent['path'] refers to the path of the directory
298+
* that was passed to readdir. So, somewhat counterintuitively, this
299+
* property refers to the *parent* path, not the path object itself.
300+
* For root entries, it's the path to the entry itself.
301+
*/
302+
get path() {
303+
return (this.parent || this).fullpath();
304+
}
294305
/**
295306
* Do not create new Path objects directly. They should always be accessed
296307
* via the PathScurry class or other methods on the Path class.
@@ -438,8 +449,7 @@ class PathBase {
438449
return (this.#relative = this.name);
439450
}
440451
const pv = p.relative();
441-
const rp = pv + (!pv || !p.parent ? '' : this.sep) + name;
442-
return (this.#relative = rp);
452+
return pv + (!pv || !p.parent ? '' : this.sep) + name;
443453
}
444454
/**
445455
* The relative path from the cwd, using / as the path separator.
@@ -458,8 +468,7 @@ class PathBase {
458468
return (this.#relativePosix = this.fullpathPosix());
459469
}
460470
const pv = p.relativePosix();
461-
const rp = pv + (!pv || !p.parent ? '' : '/') + name;
462-
return (this.#relativePosix = rp);
471+
return pv + (!pv || !p.parent ? '' : '/') + name;
463472
}
464473
/**
465474
* The fully resolved path string for this Path entry
@@ -1111,6 +1120,33 @@ class PathBase {
11111120
this.#markENOREALPATH();
11121121
}
11131122
}
1123+
/**
1124+
* Internal method to mark this Path object as the scurry cwd,
1125+
* called by {@link PathScurry#chdir}
1126+
*
1127+
* @internal
1128+
*/
1129+
[setAsCwd](oldCwd) {
1130+
if (oldCwd === this)
1131+
return;
1132+
const changed = new Set([]);
1133+
let rp = [];
1134+
let p = this;
1135+
while (p && p.parent) {
1136+
changed.add(p);
1137+
p.#relative = rp.join(this.sep);
1138+
p.#relativePosix = rp.join('/');
1139+
p = p.parent;
1140+
rp.push('..');
1141+
}
1142+
// now un-memoize parents of old cwd
1143+
p = oldCwd;
1144+
while (p && p.parent && !changed.has(p)) {
1145+
p.#relative = undefined;
1146+
p.#relativePosix = undefined;
1147+
p = p.parent;
1148+
}
1149+
}
11141150
}
11151151
exports.PathBase = PathBase;
11161152
/**
@@ -1838,6 +1874,11 @@ class PathScurryBase {
18381874
process();
18391875
return results;
18401876
}
1877+
chdir(path = this.cwd) {
1878+
const oldCwd = this.cwd;
1879+
this.cwd = typeof path === 'string' ? this.cwd.resolve(path) : path;
1880+
this.cwd[setAsCwd](oldCwd);
1881+
}
18411882
}
18421883
exports.PathScurryBase = PathScurryBase;
18431884
/**

node_modules/path-scurry/dist/mjs/index.js

+45-4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export class ChildrenCache extends LRUCache {
131131
});
132132
}
133133
}
134+
const setAsCwd = Symbol('PathScurry setAsCwd');
134135
/**
135136
* Path objects are sort of like a super-powered
136137
* {@link https://nodejs.org/docs/latest/api/fs.html#class-fsdirent fs.Dirent}
@@ -263,6 +264,16 @@ export class PathBase {
263264
#children;
264265
#linkTarget;
265266
#realpath;
267+
/**
268+
* This property is for compatibility with the Dirent class as of
269+
* Node v20, where Dirent['path'] refers to the path of the directory
270+
* that was passed to readdir. So, somewhat counterintuitively, this
271+
* property refers to the *parent* path, not the path object itself.
272+
* For root entries, it's the path to the entry itself.
273+
*/
274+
get path() {
275+
return (this.parent || this).fullpath();
276+
}
266277
/**
267278
* Do not create new Path objects directly. They should always be accessed
268279
* via the PathScurry class or other methods on the Path class.
@@ -410,8 +421,7 @@ export class PathBase {
410421
return (this.#relative = this.name);
411422
}
412423
const pv = p.relative();
413-
const rp = pv + (!pv || !p.parent ? '' : this.sep) + name;
414-
return (this.#relative = rp);
424+
return pv + (!pv || !p.parent ? '' : this.sep) + name;
415425
}
416426
/**
417427
* The relative path from the cwd, using / as the path separator.
@@ -430,8 +440,7 @@ export class PathBase {
430440
return (this.#relativePosix = this.fullpathPosix());
431441
}
432442
const pv = p.relativePosix();
433-
const rp = pv + (!pv || !p.parent ? '' : '/') + name;
434-
return (this.#relativePosix = rp);
443+
return pv + (!pv || !p.parent ? '' : '/') + name;
435444
}
436445
/**
437446
* The fully resolved path string for this Path entry
@@ -1083,6 +1092,33 @@ export class PathBase {
10831092
this.#markENOREALPATH();
10841093
}
10851094
}
1095+
/**
1096+
* Internal method to mark this Path object as the scurry cwd,
1097+
* called by {@link PathScurry#chdir}
1098+
*
1099+
* @internal
1100+
*/
1101+
[setAsCwd](oldCwd) {
1102+
if (oldCwd === this)
1103+
return;
1104+
const changed = new Set([]);
1105+
let rp = [];
1106+
let p = this;
1107+
while (p && p.parent) {
1108+
changed.add(p);
1109+
p.#relative = rp.join(this.sep);
1110+
p.#relativePosix = rp.join('/');
1111+
p = p.parent;
1112+
rp.push('..');
1113+
}
1114+
// now un-memoize parents of old cwd
1115+
p = oldCwd;
1116+
while (p && p.parent && !changed.has(p)) {
1117+
p.#relative = undefined;
1118+
p.#relativePosix = undefined;
1119+
p = p.parent;
1120+
}
1121+
}
10861122
}
10871123
/**
10881124
* Path class used on win32 systems
@@ -1807,6 +1843,11 @@ export class PathScurryBase {
18071843
process();
18081844
return results;
18091845
}
1846+
chdir(path = this.cwd) {
1847+
const oldCwd = this.cwd;
1848+
this.cwd = typeof path === 'string' ? this.cwd.resolve(path) : path;
1849+
this.cwd[setAsCwd](oldCwd);
1850+
}
18101851
}
18111852
/**
18121853
* Windows implementation of {@link PathScurryBase}

node_modules/path-scurry/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "path-scurry",
3-
"version": "1.7.0",
3+
"version": "1.9.1",
44
"description": "walk paths fast and efficiently",
55
"author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me)",
66
"main": "./dist/cjs/index.js",
@@ -58,7 +58,7 @@
5858
},
5959
"devDependencies": {
6060
"@nodelib/fs.walk": "^1.2.8",
61-
"@types/node": "^18.11.18",
61+
"@types/node": "^20.1.4",
6262
"@types/tap": "^15.0.7",
6363
"c8": "^7.12.0",
6464
"eslint-config-prettier": "^8.6.0",
@@ -81,7 +81,7 @@
8181
"url": "git+https://github.com/isaacs/path-walker"
8282
},
8383
"dependencies": {
84-
"lru-cache": "^9.0.0",
85-
"minipass": "^5.0.0"
84+
"lru-cache": "^9.1.1",
85+
"minipass": "^5.0.0 || ^6.0.0"
8686
}
8787
}

package-lock.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -10269,13 +10269,13 @@
1026910269
"dev": true
1027010270
},
1027110271
"node_modules/path-scurry": {
10272-
"version": "1.7.0",
10273-
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.7.0.tgz",
10274-
"integrity": "sha512-UkZUeDjczjYRE495+9thsgcVgsaCPkaw80slmfVFgllxY+IO8ubTsOpFVjDPROBqJdHfVPUFRHPBV/WciOVfWg==",
10272+
"version": "1.9.1",
10273+
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.9.1.tgz",
10274+
"integrity": "sha512-UgmoiySyjFxP6tscZDgWGEAgsW5ok8W3F5CJDnnH2pozwSTGE6eH7vwTotMwATWA2r5xqdkKdxYPkwlJjAI/3g==",
1027510275
"inBundle": true,
1027610276
"dependencies": {
10277-
"lru-cache": "^9.0.0",
10278-
"minipass": "^5.0.0"
10277+
"lru-cache": "^9.1.1",
10278+
"minipass": "^5.0.0 || ^6.0.0"
1027910279
},
1028010280
"engines": {
1028110281
"node": ">=16 || 14 >=14.17"

0 commit comments

Comments
 (0)