Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update glob and path-scurry #7495

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions node_modules/glob/dist/commonjs/glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.Glob = void 0;
const minimatch_1 = require("minimatch");
const path_scurry_1 = require("path-scurry");
const url_1 = require("url");
const node_url_1 = require("node:url");
const pattern_js_1 = require("./pattern.js");
const walker_js_1 = require("./walker.js");
// if no process global, just call it linux.
Expand Down Expand Up @@ -77,7 +77,7 @@ class Glob {
this.cwd = '';
}
else if (opts.cwd instanceof URL || opts.cwd.startsWith('file://')) {
opts.cwd = (0, url_1.fileURLToPath)(opts.cwd);
opts.cwd = (0, node_url_1.fileURLToPath)(opts.cwd);
}
this.cwd = opts.cwd || '';
this.root = opts.root;
Expand Down
2 changes: 1 addition & 1 deletion node_modules/glob/dist/esm/glob.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Minimatch } from 'minimatch';
import { PathScurry, PathScurryDarwin, PathScurryPosix, PathScurryWin32, } from 'path-scurry';
import { fileURLToPath } from 'url';
import { fileURLToPath } from 'node:url';
import { Pattern } from './pattern.js';
import { GlobStream, GlobWalker } from './walker.js';
// if no process global, just call it linux.
Expand Down
4 changes: 2 additions & 2 deletions node_modules/glob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me/)",
"name": "glob",
"description": "the most correct and second fastest glob implementation in JavaScript",
"version": "10.3.12",
"version": "10.3.14",
"type": "module",
"tshy": {
"main": true,
Expand Down Expand Up @@ -70,7 +70,7 @@
"jackspeak": "^2.3.6",
"minimatch": "^9.0.1",
"minipass": "^7.0.4",
"path-scurry": "^1.10.2"
"path-scurry": "^1.11.0"
},
"devDependencies": {
"@types/node": "^20.11.30",
Expand Down
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