Skip to content

Commit

Permalink
deps: path-scurry@1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed May 9, 2024
1 parent 56a27fa commit 58f773c
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 133 deletions.
124 changes: 59 additions & 65 deletions node_modules/path-scurry/dist/commonjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathScurry = exports.Path = exports.PathScurryDarwin = exports.PathScurryPosix = exports.PathScurryWin32 = exports.PathScurryBase = exports.PathPosix = exports.PathWin32 = exports.PathBase = exports.ChildrenCache = exports.ResolveCache = void 0;
const lru_cache_1 = require("lru-cache");
const path_1 = require("path");
const url_1 = require("url");
const actualFS = __importStar(require("fs"));
const node_path_1 = require("node:path");
const node_url_1 = require("node:url");
const fs_1 = require("fs");
const actualFS = __importStar(require("node:fs"));
const realpathSync = fs_1.realpathSync.native;
// TODO: test perf of fs/promises realpath vs realpathCB,
// since the promises one uses realpath.native
const promises_1 = require("fs/promises");
const promises_1 = require("node:fs/promises");
const minipass_1 = require("minipass");
const defaultFS = {
lstatSync: fs_1.lstatSync,
Expand All @@ -48,8 +48,8 @@ const defaultFS = {
},
};
// if they just gave us require('fs') then use our default
const fsFromOption = (fsOption) => !fsOption || fsOption === defaultFS || fsOption === actualFS
? defaultFS
const fsFromOption = (fsOption) => !fsOption || fsOption === defaultFS || fsOption === actualFS ?
defaultFS
: {
...defaultFS,
...fsOption,
Expand Down Expand Up @@ -90,20 +90,13 @@ const ENOREADLINK = 0b0001_0000_0000;
const ENOREALPATH = 0b0010_0000_0000;
const ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
const TYPEMASK = 0b0011_1111_1111;
const entToType = (s) => s.isFile()
? IFREG
: s.isDirectory()
? IFDIR
: s.isSymbolicLink()
? IFLNK
: s.isCharacterDevice()
? IFCHR
: s.isBlockDevice()
? IFBLK
: s.isSocket()
? IFSOCK
: s.isFIFO()
? IFIFO
const entToType = (s) => s.isFile() ? IFREG
: s.isDirectory() ? IFDIR
: s.isSymbolicLink() ? IFLNK
: s.isCharacterDevice() ? IFCHR
: s.isBlockDevice() ? IFBLK
: s.isSocket() ? IFSOCK
: s.isFIFO() ? IFIFO
: UNKNOWN;
// normalize unicode path names
const normalizeCache = new Map();
Expand Down Expand Up @@ -207,6 +200,11 @@ class PathBase {
* @internal
*/
nocase;
/**
* boolean indicating that this path is the current working directory
* of the PathScurry collection that contains it.
*/
isCWD = false;
// potential default fs override
#fs;
// Stats fields
Expand Down Expand Up @@ -294,14 +292,20 @@ class PathBase {
#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.
* Node v20, where Dirent['parentPath'] refers to the path of the
* directory that was passed to readdir. For root entries, it's the path
* to the entry itself.
*/
get path() {
get parentPath() {
return (this.parent || this).fullpath();
}
/**
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
* this property refers to the *parent* path, not the path object itself.
*/
get path() {
return this.parentPath;
}
/**
* 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 @@ -355,8 +359,8 @@ class PathBase {
const rootPath = this.getRootString(path);
const dir = path.substring(rootPath.length);
const dirParts = dir.split(this.splitSep);
const result = rootPath
? this.getRoot(rootPath).#resolveParts(dirParts)
const result = rootPath ?
this.getRoot(rootPath).#resolveParts(dirParts)
: this.#resolveParts(dirParts);
return result;
}
Expand Down Expand Up @@ -407,9 +411,7 @@ class PathBase {
}
// find the child
const children = this.children();
const name = this.nocase
? normalizeNocase(pathPart)
: normalize(pathPart);
const name = this.nocase ? normalizeNocase(pathPart) : normalize(pathPart);
for (const p of children) {
if (p.#matchName === name) {
return p;
Expand All @@ -419,9 +421,7 @@ class PathBase {
// actually exist. If we know the parent isn't a dir, then
// in fact it CAN'T exist.
const s = this.parent ? this.sep : '';
const fullpath = this.#fullpath
? this.#fullpath + s + pathPart
: undefined;
const fullpath = this.#fullpath ? this.#fullpath + s + pathPart : undefined;
const pchild = this.newChild(pathPart, UNKNOWN, {
...opts,
parent: this,
Expand All @@ -440,6 +440,8 @@ class PathBase {
* the cwd, then this ends up being equivalent to the fullpath()
*/
relative() {
if (this.isCWD)
return '';
if (this.#relative !== undefined) {
return this.#relative;
}
Expand All @@ -460,6 +462,8 @@ class PathBase {
relativePosix() {
if (this.sep === '/')
return this.relative();
if (this.isCWD)
return '';
if (this.#relativePosix !== undefined)
return this.#relativePosix;
const name = this.name;
Expand Down Expand Up @@ -525,23 +529,15 @@ class PathBase {
return this[`is${type}`]();
}
getType() {
return this.isUnknown()
? 'Unknown'
: this.isDirectory()
? 'Directory'
: this.isFile()
? 'File'
: this.isSymbolicLink()
? 'SymbolicLink'
: this.isFIFO()
? 'FIFO'
: this.isCharacterDevice()
? 'CharacterDevice'
: this.isBlockDevice()
? 'BlockDevice'
: /* c8 ignore start */ this.isSocket()
? 'Socket'
: 'Unknown';
return (this.isUnknown() ? 'Unknown'
: this.isDirectory() ? 'Directory'
: this.isFile() ? 'File'
: this.isSymbolicLink() ? 'SymbolicLink'
: this.isFIFO() ? 'FIFO'
: this.isCharacterDevice() ? 'CharacterDevice'
: this.isBlockDevice() ? 'BlockDevice'
: /* c8 ignore start */ this.isSocket() ? 'Socket'
: 'Unknown');
/* c8 ignore stop */
}
/**
Expand Down Expand Up @@ -675,8 +671,8 @@ class PathBase {
* directly.
*/
isNamed(n) {
return !this.nocase
? this.#matchName === normalize(n)
return !this.nocase ?
this.#matchName === normalize(n)
: this.#matchName === normalizeNocase(n);
}
/**
Expand Down Expand Up @@ -732,7 +728,7 @@ class PathBase {
/* c8 ignore stop */
try {
const read = this.#fs.readlinkSync(this.fullpath());
const linkTarget = (this.parent.realpathSync())?.resolve(read);
const linkTarget = this.parent.realpathSync()?.resolve(read);
if (linkTarget) {
return (this.#linkTarget = linkTarget);
}
Expand Down Expand Up @@ -853,9 +849,7 @@ class PathBase {
#readdirMaybePromoteChild(e, c) {
for (let p = c.provisional; p < c.length; p++) {
const pchild = c[p];
const name = this.nocase
? normalizeNocase(e.name)
: normalize(e.name);
const name = this.nocase ? normalizeNocase(e.name) : normalize(e.name);
if (name !== pchild.#matchName) {
continue;
}
Expand Down Expand Up @@ -1154,6 +1148,8 @@ class PathBase {
[setAsCwd](oldCwd) {
if (oldCwd === this)
return;
oldCwd.isCWD = false;
this.isCWD = true;
const changed = new Set([]);
let rp = [];
let p = this;
Expand Down Expand Up @@ -1208,7 +1204,7 @@ class PathWin32 extends PathBase {
* @internal
*/
getRootString(path) {
return path_1.win32.parse(path).root;
return node_path_1.win32.parse(path).root;
}
/**
* @internal
Expand Down Expand Up @@ -1330,7 +1326,7 @@ class PathScurryBase {
constructor(cwd = process.cwd(), pathImpl, sep, { nocase, childrenCacheSize = 16 * 1024, fs = defaultFS, } = {}) {
this.#fs = fsFromOption(fs);
if (cwd instanceof URL || cwd.startsWith('file://')) {
cwd = (0, url_1.fileURLToPath)(cwd);
cwd = (0, node_url_1.fileURLToPath)(cwd);
}
// resolve and split root, and then add to the store.
// this is the only time we call path.resolve()
Expand Down Expand Up @@ -1919,7 +1915,7 @@ class PathScurryWin32 extends PathScurryBase {
sep = '\\';
constructor(cwd = process.cwd(), opts = {}) {
const { nocase = true } = opts;
super(cwd, path_1.win32, '\\', { ...opts, nocase });
super(cwd, node_path_1.win32, '\\', { ...opts, nocase });
this.nocase = nocase;
for (let p = this.cwd; p; p = p.parent) {
p.nocase = this.nocase;
Expand All @@ -1932,7 +1928,7 @@ class PathScurryWin32 extends PathScurryBase {
// if the path starts with a single separator, it's not a UNC, and we'll
// just get separator as the root, and driveFromUNC will return \
// In that case, mount \ on the root from the cwd.
return path_1.win32.parse(dir).root.toUpperCase();
return node_path_1.win32.parse(dir).root.toUpperCase();
}
/**
* @internal
Expand Down Expand Up @@ -1962,7 +1958,7 @@ class PathScurryPosix extends PathScurryBase {
sep = '/';
constructor(cwd = process.cwd(), opts = {}) {
const { nocase = false } = opts;
super(cwd, path_1.posix, '/', { ...opts, nocase });
super(cwd, node_path_1.posix, '/', { ...opts, nocase });
this.nocase = nocase;
}
/**
Expand Down Expand Up @@ -2012,9 +2008,7 @@ exports.Path = process.platform === 'win32' ? PathWin32 : PathPosix;
* {@link PathScurryWin32} on Windows systems, {@link PathScurryDarwin} on
* Darwin (macOS) systems, {@link PathScurryPosix} on all others.
*/
exports.PathScurry = process.platform === 'win32'
? PathScurryWin32
: process.platform === 'darwin'
? PathScurryDarwin
exports.PathScurry = process.platform === 'win32' ? PathScurryWin32
: process.platform === 'darwin' ? PathScurryDarwin
: PathScurryPosix;
//# sourceMappingURL=index.js.map

0 comments on commit 58f773c

Please sign in to comment.