From c6272c64822f5357ea75e1767f09bba69b6c0415 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Tue, 14 Nov 2023 19:59:22 +0100 Subject: [PATCH] [yarn] Upgrade to v4.0.2 --- .pnp.cjs | 28 ++++++++++++++-- .pnp.loader.mjs | 89 ++++++++++++++++++++++++++++++++++--------------- package.json | 2 +- 3 files changed, 89 insertions(+), 30 deletions(-) diff --git a/.pnp.cjs b/.pnp.cjs index 9959ddda4..04ec38280 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -34185,6 +34185,12 @@ class ProxiedFS extends FakeFS { } } +function direntToPortable(dirent) { + const portableDirent = dirent; + if (typeof dirent.path === `string`) + portableDirent.path = npath.toPortablePath(dirent.path); + return portableDirent; +} class NodeFS extends BasePortableFakeFS { constructor(realFs = fs__default.default) { super(); @@ -34511,15 +34517,31 @@ class NodeFS extends BasePortableFakeFS { async readdirPromise(p, opts) { return await new Promise((resolve, reject) => { if (opts) { - this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + if (opts.recursive && process.platform === `win32`) { + if (opts.withFileTypes) { + this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(direntToPortable)), reject)); + } else { + this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(npath.toPortablePath)), reject)); + } + } else { + this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + } } else { - this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback((value) => resolve(value), reject)); + this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); } }); } readdirSync(p, opts) { if (opts) { - return this.realFs.readdirSync(npath.fromPortablePath(p), opts); + if (opts.recursive && process.platform === `win32`) { + if (opts.withFileTypes) { + return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(direntToPortable); + } else { + return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(npath.toPortablePath); + } + } else { + return this.realFs.readdirSync(npath.fromPortablePath(p), opts); + } } else { return this.realFs.readdirSync(npath.fromPortablePath(p)); } diff --git a/.pnp.loader.mjs b/.pnp.loader.mjs index 928eae83b..fe96ee1d6 100644 --- a/.pnp.loader.mjs +++ b/.pnp.loader.mjs @@ -902,6 +902,12 @@ class ProxiedFS extends FakeFS { } } +function direntToPortable(dirent) { + const portableDirent = dirent; + if (typeof dirent.path === `string`) + portableDirent.path = npath.toPortablePath(dirent.path); + return portableDirent; +} class NodeFS extends BasePortableFakeFS { constructor(realFs = fs) { super(); @@ -1228,15 +1234,31 @@ class NodeFS extends BasePortableFakeFS { async readdirPromise(p, opts) { return await new Promise((resolve, reject) => { if (opts) { - this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + if (opts.recursive && process.platform === `win32`) { + if (opts.withFileTypes) { + this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(direntToPortable)), reject)); + } else { + this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(npath.toPortablePath)), reject)); + } + } else { + this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); + } } else { - this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback((value) => resolve(value), reject)); + this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback(resolve, reject)); } }); } readdirSync(p, opts) { if (opts) { - return this.realFs.readdirSync(npath.fromPortablePath(p), opts); + if (opts.recursive && process.platform === `win32`) { + if (opts.withFileTypes) { + return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(direntToPortable); + } else { + return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(npath.toPortablePath); + } + } else { + return this.realFs.readdirSync(npath.fromPortablePath(p), opts); + } } else { return this.realFs.readdirSync(npath.fromPortablePath(p)); } @@ -1372,7 +1394,7 @@ class VirtualFS extends ProxiedFS { const [major, minor] = process.versions.node.split(`.`).map((value) => parseInt(value, 10)); const WATCH_MODE_MESSAGE_USES_ARRAYS = major > 19 || major === 19 && minor >= 2 || major === 18 && minor >= 13; -const HAS_LAZY_LOADED_TRANSLATORS = major > 19 || major === 19 && minor >= 3; +const HAS_LAZY_LOADED_TRANSLATORS = major === 20 && minor < 6 || major === 19 && minor >= 3; function readPackageScope(checkPath) { const rootSeparatorIndex = checkPath.indexOf(npath.sep); @@ -2020,31 +2042,46 @@ async function resolve$1(originalSpecifier, context, nextResolve) { if (!HAS_LAZY_LOADED_TRANSLATORS) { const binding = process.binding(`fs`); - const originalfstat = binding.fstat; - const ZIP_MASK = 4278190080; - const ZIP_MAGIC = 704643072; - binding.fstat = function(...args) { - const [fd, useBigint, req] = args; - if ((fd & ZIP_MASK) === ZIP_MAGIC && useBigint === false && req === void 0) { + const originalReadFile = binding.readFileUtf8 || binding.readFileSync; + if (originalReadFile) { + binding[originalReadFile.name] = function(...args) { try { - const stats = fs.fstatSync(fd); - return new Float64Array([ - stats.dev, - stats.mode, - stats.nlink, - stats.uid, - stats.gid, - stats.rdev, - stats.blksize, - stats.ino, - stats.size, - stats.blocks - ]); + return fs.readFileSync(args[0], { + encoding: `utf8`, + flag: args[1] + }); } catch { } - } - return originalfstat.apply(this, args); - }; + return originalReadFile.apply(this, args); + }; + } else { + const binding2 = process.binding(`fs`); + const originalfstat = binding2.fstat; + const ZIP_MASK = 4278190080; + const ZIP_MAGIC = 704643072; + binding2.fstat = function(...args) { + const [fd, useBigint, req] = args; + if ((fd & ZIP_MASK) === ZIP_MAGIC && useBigint === false && req === void 0) { + try { + const stats = fs.fstatSync(fd); + return new Float64Array([ + stats.dev, + stats.mode, + stats.nlink, + stats.uid, + stats.gid, + stats.rdev, + stats.blksize, + stats.ino, + stats.size, + stats.blocks + ]); + } catch { + } + } + return originalfstat.apply(this, args); + }; + } } const resolve = resolve$1; diff --git a/package.json b/package.json index 8d1794db2..c749c2695 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "start-server-and-test": "1.15.2", "typescript": "5.1.6" }, - "packageManager": "yarn@4.0.1+sha256.5a9d054e67fbbae8774cd3667736fd74407ffbbb336898523ca1fe87b3fc4ee3", + "packageManager": "yarn@4.0.2", "dependenciesMeta": { "@discordapp/twemoji@14.1.2": { "unplugged": true