From 9eab04b5a1f142f7014764357803eed03db7f64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Sat, 9 Mar 2024 20:45:03 +0100 Subject: [PATCH] Marks the "path" property as always-there when withFileTypes is set --- .yarn/versions/380a70a7.yml | 36 +++++++++++++++++++ packages/yarnpkg-fslib/sources/FakeFS.ts | 20 +++++------ packages/yarnpkg-fslib/sources/MountFS.ts | 22 ++++++------ packages/yarnpkg-fslib/sources/NodeFS.ts | 32 ++++++++--------- packages/yarnpkg-fslib/sources/ProxiedFS.ts | 30 ++++++++-------- packages/yarnpkg-fslib/tests/FakeFS.types.ts | 4 +-- packages/yarnpkg-libzip/sources/ZipFS.ts | 24 ++++++------- .../yarnpkg-pnpify/sources/NodeModulesFS.ts | 26 +++++++------- 8 files changed, 115 insertions(+), 79 deletions(-) create mode 100644 .yarn/versions/380a70a7.yml diff --git a/.yarn/versions/380a70a7.yml b/.yarn/versions/380a70a7.yml new file mode 100644 index 00000000000..700622d30b3 --- /dev/null +++ b/.yarn/versions/380a70a7.yml @@ -0,0 +1,36 @@ +releases: + "@yarnpkg/fslib": patch + "@yarnpkg/libzip": patch + "@yarnpkg/pnpify": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-exec" + - "@yarnpkg/plugin-file" + - "@yarnpkg/plugin-git" + - "@yarnpkg/plugin-github" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-link" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - vscode-zipfs + - "@yarnpkg/builder" + - "@yarnpkg/cli" + - "@yarnpkg/core" + - "@yarnpkg/doctor" + - "@yarnpkg/nm" + - "@yarnpkg/pnp" + - "@yarnpkg/sdks" + - "@yarnpkg/shell" diff --git a/packages/yarnpkg-fslib/sources/FakeFS.ts b/packages/yarnpkg-fslib/sources/FakeFS.ts index 1ed15d93929..7ff03b557ce 100644 --- a/packages/yarnpkg-fslib/sources/FakeFS.ts +++ b/packages/yarnpkg-fslib/sources/FakeFS.ts @@ -172,28 +172,28 @@ export abstract class FakeFS

{ abstract realpathSync(p: P): P; abstract readdirPromise(p: P, opts?: null): Promise>; - abstract readdirPromise(p: P, opts: {recursive?: false, withFileTypes: true}): Promise>; + abstract readdirPromise(p: P, opts: {recursive?: false, withFileTypes: true}): Promise>>; abstract readdirPromise(p: P, opts: {recursive?: false, withFileTypes?: false}): Promise>; - abstract readdirPromise(p: P, opts: {recursive?: false, withFileTypes: boolean}): Promise>; + abstract readdirPromise(p: P, opts: {recursive?: false, withFileTypes: boolean}): Promise | Filename>>; abstract readdirPromise(p: P, opts: {recursive: true, withFileTypes: true}): Promise>>; abstract readdirPromise(p: P, opts: {recursive: true, withFileTypes?: false}): Promise>; abstract readdirPromise(p: P, opts: {recursive: true, withFileTypes: boolean}): Promise | P>>; - abstract readdirPromise(p: P, opts: {recursive: boolean, withFileTypes: true}): Promise | DirentNoPath>>; + abstract readdirPromise(p: P, opts: {recursive: boolean, withFileTypes: true}): Promise>>; abstract readdirPromise(p: P, opts: {recursive: boolean, withFileTypes?: false}): Promise>; - abstract readdirPromise(p: P, opts: {recursive: boolean, withFileTypes: boolean}): Promise | DirentNoPath | P>>; - abstract readdirPromise(p: P, opts?: ReaddirOptions | null): Promise | DirentNoPath | P>>; + abstract readdirPromise(p: P, opts: {recursive: boolean, withFileTypes: boolean}): Promise | P>>; + abstract readdirPromise(p: P, opts?: ReaddirOptions | null): Promise | P>>; abstract readdirSync(p: P, opts?: null): Array; - abstract readdirSync(p: P, opts: {recursive?: false, withFileTypes: true}): Array; + abstract readdirSync(p: P, opts: {recursive?: false, withFileTypes: true}): Array>; abstract readdirSync(p: P, opts: {recursive?: false, withFileTypes?: false}): Array; - abstract readdirSync(p: P, opts: {recursive?: false, withFileTypes: boolean}): Array; + abstract readdirSync(p: P, opts: {recursive?: false, withFileTypes: boolean}): Array | Filename>; abstract readdirSync(p: P, opts: {recursive: true, withFileTypes: true}): Array>; abstract readdirSync(p: P, opts: {recursive: true, withFileTypes?: false}): Array

; abstract readdirSync(p: P, opts: {recursive: true, withFileTypes: boolean}): Array | P>; - abstract readdirSync(p: P, opts: {recursive: boolean, withFileTypes: true}): Array | DirentNoPath>; + abstract readdirSync(p: P, opts: {recursive: boolean, withFileTypes: true}): Array>; abstract readdirSync(p: P, opts: {recursive: boolean, withFileTypes?: false}): Array

; - abstract readdirSync(p: P, opts: {recursive: boolean, withFileTypes: boolean}): Array | DirentNoPath | P>; - abstract readdirSync(p: P, opts?: ReaddirOptions | null): Array | DirentNoPath | P>; + abstract readdirSync(p: P, opts: {recursive: boolean, withFileTypes: boolean}): Array | P>; + abstract readdirSync(p: P, opts?: ReaddirOptions | null): Array | P>; abstract existsPromise(p: P): Promise; abstract existsSync(p: P): boolean; diff --git a/packages/yarnpkg-fslib/sources/MountFS.ts b/packages/yarnpkg-fslib/sources/MountFS.ts index 655a0007eb4..19e462bdabe 100644 --- a/packages/yarnpkg-fslib/sources/MountFS.ts +++ b/packages/yarnpkg-fslib/sources/MountFS.ts @@ -1,6 +1,6 @@ import {BigIntStats, constants, Stats} from 'fs'; -import {WatchOptions, WatchCallback, Watcher, StatOptions, StatSyncOptions, ReaddirOptions, DirentNoPath} from './FakeFS'; +import {WatchOptions, WatchCallback, Watcher, StatOptions, StatSyncOptions, ReaddirOptions} from './FakeFS'; import {FakeFS, MkdirOptions, RmdirOptions, WriteFileOptions, OpendirOptions} from './FakeFS'; import {Dirent, SymlinkType} from './FakeFS'; import {CreateReadStreamOptions, CreateWriteStreamOptions, BasePortableFakeFS, ExtractHintOptions, WatchFileOptions, WatchFileCallback, StatWatcher} from './FakeFS'; @@ -807,16 +807,16 @@ export class MountFS extends BasePortableFakeFS { } async readdirPromise(p: PortablePath, opts?: null): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Promise>; + async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes?: false}): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Promise>; + async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Promise | Filename>>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes?: false}): Promise>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes: boolean}): Promise | PortablePath>>; - async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Promise | DirentNoPath>>; + async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes?: false}): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Promise | DirentNoPath | PortablePath>>; - async readdirPromise(p: PortablePath, opts?: ReaddirOptions | null): Promise | DirentNoPath | PortablePath>> { + async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Promise | PortablePath>>; + async readdirPromise(p: PortablePath, opts?: ReaddirOptions | null): Promise | PortablePath>> { return await this.makeCallPromise(p, async () => { return await this.baseFs.readdirPromise(p, opts as any); }, async (mountFs, {subPath}) => { @@ -827,16 +827,16 @@ export class MountFS extends BasePortableFakeFS { } readdirSync(p: PortablePath, opts?: null): Array; - readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Array; + readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes?: false}): Array; - readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Array; + readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Array | Filename>; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes?: false}): Array; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes: boolean}): Array | PortablePath>; - readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Array | DirentNoPath>; + readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes?: false}): Array; - readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Array | DirentNoPath | PortablePath>; - readdirSync(p: PortablePath, opts?: ReaddirOptions | null): Array | DirentNoPath | PortablePath> { + readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Array | PortablePath>; + readdirSync(p: PortablePath, opts?: ReaddirOptions | null): Array | PortablePath> { return this.makeCallSync(p, () => { return this.baseFs.readdirSync(p, opts as any); }, (mountFs, {subPath}) => { diff --git a/packages/yarnpkg-fslib/sources/NodeFS.ts b/packages/yarnpkg-fslib/sources/NodeFS.ts index 9e6ec81349e..19b82adb3a9 100644 --- a/packages/yarnpkg-fslib/sources/NodeFS.ts +++ b/packages/yarnpkg-fslib/sources/NodeFS.ts @@ -1,10 +1,10 @@ -import fs, {BigIntStats, Stats} from 'fs'; +import fs, {BigIntStats, Stats} from 'fs'; -import {CreateReadStreamOptions, CreateWriteStreamOptions, Dir, StatWatcher, WatchFileCallback, WatchFileOptions, OpendirOptions, ReaddirOptions, DirentNoPath} from './FakeFS'; -import {Dirent, SymlinkType, StatSyncOptions, StatOptions} from './FakeFS'; -import {BasePortableFakeFS, WriteFileOptions} from './FakeFS'; -import {MkdirOptions, RmdirOptions, WatchOptions, WatchCallback, Watcher} from './FakeFS'; -import {FSPath, PortablePath, Filename, ppath, npath, NativePath} from './path'; +import {CreateReadStreamOptions, CreateWriteStreamOptions, Dir, StatWatcher, WatchFileCallback, WatchFileOptions, OpendirOptions, ReaddirOptions} from './FakeFS'; +import {Dirent, SymlinkType, StatSyncOptions, StatOptions} from './FakeFS'; +import {BasePortableFakeFS, WriteFileOptions} from './FakeFS'; +import {MkdirOptions, RmdirOptions, WatchOptions, WatchCallback, Watcher} from './FakeFS'; +import {FSPath, PortablePath, Filename, ppath, npath, NativePath} from './path'; function direntToPortable(dirent: Dirent): Dirent { // We don't need to return a copy, we can just reuse the object the real fs returned @@ -467,16 +467,16 @@ export class NodeFS extends BasePortableFakeFS { } async readdirPromise(p: PortablePath, opts?: null): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Promise>; + async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes?: false}): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Promise>; + async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Promise | Filename>>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes?: false}): Promise>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes: boolean}): Promise | PortablePath>>; - async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Promise | DirentNoPath>>; + async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes?: false}): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Promise | DirentNoPath | PortablePath>>; - async readdirPromise(p: PortablePath, opts?: ReaddirOptions | null): Promise | DirentNoPath | PortablePath>> { + async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Promise | PortablePath>>; + async readdirPromise(p: PortablePath, opts?: ReaddirOptions | null): Promise | PortablePath>> { return await new Promise((resolve, reject) => { if (opts) { if (opts.recursive && process.platform === `win32`) { @@ -495,16 +495,16 @@ export class NodeFS extends BasePortableFakeFS { } readdirSync(p: PortablePath, opts?: null): Array; - readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Array; + readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes?: false}): Array; - readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Array; + readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Array | Filename>; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes?: false}): Array; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes: boolean}): Array | PortablePath>; - readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Array | DirentNoPath>; + readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes?: false}): Array; - readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Array | DirentNoPath | PortablePath>; - readdirSync(p: PortablePath, opts?: ReaddirOptions | null): Array | DirentNoPath | PortablePath> { + readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Array | Dirent | PortablePath>; + readdirSync(p: PortablePath, opts?: ReaddirOptions | null): Array | PortablePath> { if (opts) { if (opts.recursive && process.platform === `win32`) { if (opts.withFileTypes) { diff --git a/packages/yarnpkg-fslib/sources/ProxiedFS.ts b/packages/yarnpkg-fslib/sources/ProxiedFS.ts index 5c69773b0f8..02285157318 100644 --- a/packages/yarnpkg-fslib/sources/ProxiedFS.ts +++ b/packages/yarnpkg-fslib/sources/ProxiedFS.ts @@ -1,9 +1,9 @@ -import {Stats, BigIntStats} from 'fs'; +import {Stats, BigIntStats} from 'fs'; -import {CreateReadStreamOptions, CreateWriteStreamOptions, FakeFS, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher, Dir, OpendirOptions, ReaddirOptions, DirentNoPath} from './FakeFS'; -import {Dirent, SymlinkType, StatSyncOptions, StatOptions} from './FakeFS'; -import {MkdirOptions, RmdirOptions, WriteFileOptions, WatchCallback, WatchOptions, Watcher} from './FakeFS'; -import {FSPath, Filename, Path} from './path'; +import {CreateReadStreamOptions, CreateWriteStreamOptions, FakeFS, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher, Dir, OpendirOptions, ReaddirOptions} from './FakeFS'; +import {Dirent, SymlinkType, StatSyncOptions, StatOptions} from './FakeFS'; +import {MkdirOptions, RmdirOptions, WriteFileOptions, WatchCallback, WatchOptions, Watcher} from './FakeFS'; +import {FSPath, Filename, Path} from './path'; export abstract class ProxiedFS

extends FakeFS

{ protected abstract readonly baseFs: FakeFS; @@ -317,30 +317,30 @@ export abstract class ProxiedFS

extends FakeFS< } readdirPromise(p: P, opts?: null): Promise>; - readdirPromise(p: P, opts: {recursive?: false, withFileTypes: true}): Promise>; + readdirPromise(p: P, opts: {recursive?: false, withFileTypes: true}): Promise>>; readdirPromise(p: P, opts: {recursive?: false, withFileTypes?: false}): Promise>; - readdirPromise(p: P, opts: {recursive?: false, withFileTypes: boolean}): Promise>; + readdirPromise(p: P, opts: {recursive?: false, withFileTypes: boolean}): Promise | Filename>>; readdirPromise(p: P, opts: {recursive: true, withFileTypes: true}): Promise>>; readdirPromise(p: P, opts: {recursive: true, withFileTypes?: false}): Promise>; readdirPromise(p: P, opts: {recursive: true, withFileTypes: boolean}): Promise | P>>; - readdirPromise(p: P, opts: {recursive: boolean, withFileTypes: true}): Promise | DirentNoPath>>; + readdirPromise(p: P, opts: {recursive: boolean, withFileTypes: true}): Promise>>; readdirPromise(p: P, opts: {recursive: boolean, withFileTypes?: false}): Promise>; - readdirPromise(p: P, opts: {recursive: boolean, withFileTypes: boolean}): Promise | DirentNoPath | P>>; - readdirPromise(p: P, opts?: ReaddirOptions | null): Promise | DirentNoPath | P | Filename>> { + readdirPromise(p: P, opts: {recursive: boolean, withFileTypes: boolean}): Promise | P>>; + readdirPromise(p: P, opts?: ReaddirOptions | null): Promise | P | Filename>> { return this.baseFs.readdirPromise(this.mapToBase(p), opts as any); } readdirSync(p: P, opts?: null): Array; - readdirSync(p: P, opts: {recursive?: false, withFileTypes: true}): Array; + readdirSync(p: P, opts: {recursive?: false, withFileTypes: true}): Array>; readdirSync(p: P, opts: {recursive?: false, withFileTypes?: false}): Array; - readdirSync(p: P, opts: {recursive?: false, withFileTypes: boolean}): Array; + readdirSync(p: P, opts: {recursive?: false, withFileTypes: boolean}): Array | Filename>; readdirSync(p: P, opts: {recursive: true, withFileTypes: true}): Array>; readdirSync(p: P, opts: {recursive: true, withFileTypes?: false}): Array

; readdirSync(p: P, opts: {recursive: true, withFileTypes: boolean}): Array | P>; - readdirSync(p: P, opts: {recursive: boolean, withFileTypes: true}): Array | DirentNoPath>; + readdirSync(p: P, opts: {recursive: boolean, withFileTypes: true}): Array>; readdirSync(p: P, opts: {recursive: boolean, withFileTypes?: false}): Array

; - readdirSync(p: P, opts: {recursive: boolean, withFileTypes: boolean}): Array | DirentNoPath | P>; - readdirSync(p: P, opts?: ReaddirOptions | null): Array | DirentNoPath | P | Filename> { + readdirSync(p: P, opts: {recursive: boolean, withFileTypes: boolean}): Array | P>; + readdirSync(p: P, opts?: ReaddirOptions | null): Array | P | Filename> { return this.baseFs.readdirSync(this.mapToBase(p), opts as any); } diff --git a/packages/yarnpkg-fslib/tests/FakeFS.types.ts b/packages/yarnpkg-fslib/tests/FakeFS.types.ts index de8fe7aad39..a485fa91119 100644 --- a/packages/yarnpkg-fslib/tests/FakeFS.types.ts +++ b/packages/yarnpkg-fslib/tests/FakeFS.types.ts @@ -1,4 +1,4 @@ -import {Dirent, DirentNoPath, FakeFS, Filename, PortablePath} from '../sources'; +import {Dirent, FakeFS, Filename, PortablePath} from '../sources'; declare const fakeFs: FakeFS; @@ -18,5 +18,5 @@ Promise.resolve().then(async () => { assertEqual>>()(await fakeFs.readdirPromise(PortablePath.dot, {recursive: true, withFileTypes: true}), true); assertEqual>()(await fakeFs.readdirPromise(PortablePath.dot, {recursive: false}), true); - assertEqual>()(await fakeFs.readdirPromise(PortablePath.dot, {recursive: false, withFileTypes: true}), true); + assertEqual>>()(await fakeFs.readdirPromise(PortablePath.dot, {recursive: false, withFileTypes: true}), true); }); diff --git a/packages/yarnpkg-libzip/sources/ZipFS.ts b/packages/yarnpkg-libzip/sources/ZipFS.ts index 33d1e1f5685..db3bfac61e1 100644 --- a/packages/yarnpkg-libzip/sources/ZipFS.ts +++ b/packages/yarnpkg-libzip/sources/ZipFS.ts @@ -1,4 +1,4 @@ -import {Dirent, DirentNoPath, ReaddirOptions} from '@yarnpkg/fslib'; +import {Dirent, ReaddirOptions} from '@yarnpkg/fslib'; import {WatchOptions, WatchCallback, Watcher, Dir, Stats, BigIntStats, StatSyncOptions, StatOptions} from '@yarnpkg/fslib'; import {FakeFS, MkdirOptions, RmdirOptions, WriteFileOptions, OpendirOptions} from '@yarnpkg/fslib'; import {CreateReadStreamOptions, CreateWriteStreamOptions, BasePortableFakeFS, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher} from '@yarnpkg/fslib'; @@ -1453,30 +1453,30 @@ export class ZipFS extends BasePortableFakeFS { } async readdirPromise(p: PortablePath, opts?: null): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Promise>; + async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes?: false}): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Promise>; + async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Promise | Filename>>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes?: false}): Promise>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes: boolean}): Promise | PortablePath>>; - async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Promise | DirentNoPath>>; + async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes?: false}): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Promise | DirentNoPath | PortablePath>>; - async readdirPromise(p: PortablePath, opts?: ReaddirOptions | null): Promise | DirentNoPath | PortablePath>> { + async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Promise | PortablePath>>; + async readdirPromise(p: PortablePath, opts?: ReaddirOptions | null): Promise | PortablePath>> { return this.readdirSync(p, opts as any); } readdirSync(p: PortablePath, opts?: null): Array; - readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Array; + readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes?: false}): Array; - readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Array; + readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Array | Filename>; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes?: false}): Array; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes: boolean}): Array | PortablePath>; - readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Array | DirentNoPath>; + readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes?: false}): Array; - readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Array | DirentNoPath | PortablePath>; - readdirSync(p: PortablePath, opts?: ReaddirOptions | null): Array | DirentNoPath | PortablePath> { + readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Array | PortablePath>; + readdirSync(p: PortablePath, opts?: ReaddirOptions | null): Array | PortablePath> { const resolvedP = this.resolveFilename(`scandir '${p}'`, p); if (!this.entries.has(resolvedP) && !this.listings.has(resolvedP)) throw errors.ENOENT(`scandir '${p}'`); @@ -1529,7 +1529,7 @@ export class ZipFS extends BasePortableFakeFS { return Array.from(directoryListing, name => { return Object.assign(this.statImpl(`lstat`, ppath.join(p, name)), { name, - path: undefined, + path: p, }); }); } else { diff --git a/packages/yarnpkg-pnpify/sources/NodeModulesFS.ts b/packages/yarnpkg-pnpify/sources/NodeModulesFS.ts index 5a2e3462f65..719a6726e03 100644 --- a/packages/yarnpkg-pnpify/sources/NodeModulesFS.ts +++ b/packages/yarnpkg-pnpify/sources/NodeModulesFS.ts @@ -1,4 +1,4 @@ -import {BigIntStats, DirentNoPath, ReaddirOptions, Stats} from '@yarnpkg/fslib'; +import {BigIntStats, ReaddirOptions, Stats} from '@yarnpkg/fslib'; import {Dirent, Filename, MkdirOptions, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher, OpendirOptions, Dir} from '@yarnpkg/fslib'; import {RmdirOptions} from '@yarnpkg/fslib'; import {FSPath, NativePath, PortablePath, npath, ppath, opendir} from '@yarnpkg/fslib'; @@ -502,16 +502,16 @@ export class PortableNodeModulesFS extends FakeFS { } async readdirPromise(p: PortablePath, opts?: null): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Promise>; + async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes?: false}): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Promise>; + async readdirPromise(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Promise | Filename>>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes?: false}): Promise>; async readdirPromise(p: PortablePath, opts: {recursive: true, withFileTypes: boolean}): Promise | PortablePath>>; - async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Promise | DirentNoPath>>; + async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Promise>>; async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes?: false}): Promise>; - async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Promise | DirentNoPath | PortablePath>>; - async readdirPromise(p: PortablePath, opts?: ReaddirOptions | null): Promise | DirentNoPath | PortablePath>> { + async readdirPromise(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Promise | PortablePath>>; + async readdirPromise(p: PortablePath, opts?: ReaddirOptions | null): Promise | PortablePath>> { const pnpPath = this.resolvePath(p); if (pnpPath.dirList || this.resolvePath(ppath.join(p, `node_modules`)).dirList) { if (opts?.recursive) @@ -531,7 +531,7 @@ export class PortableNodeModulesFS extends FakeFS { return entries.map(name => { return Object.assign(this.lstatSync(ppath.join(p, name)), { name, - path: undefined, + path: p, }); }); } else { @@ -540,16 +540,16 @@ export class PortableNodeModulesFS extends FakeFS { } readdirSync(p: PortablePath, opts?: null): Array; - readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Array; + readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes?: false}): Array; - readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Array; + readdirSync(p: PortablePath, opts: {recursive?: false, withFileTypes: boolean}): Array | Filename>; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes?: false}): Array; readdirSync(p: PortablePath, opts: {recursive: true, withFileTypes: boolean}): Array | PortablePath>; - readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Array | DirentNoPath>; + readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: true}): Array>; readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes?: false}): Array; - readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Array | DirentNoPath | PortablePath>; - readdirSync(p: PortablePath, opts?: ReaddirOptions | null): Array | DirentNoPath | PortablePath> { + readdirSync(p: PortablePath, opts: {recursive: boolean, withFileTypes: boolean}): Array | PortablePath>; + readdirSync(p: PortablePath, opts?: ReaddirOptions | null): Array | PortablePath> { const pnpPath = this.resolvePath(p); if (pnpPath.dirList || this.resolvePath(ppath.join(p, `node_modules`)).dirList) { if (opts?.recursive) @@ -569,7 +569,7 @@ export class PortableNodeModulesFS extends FakeFS { return entries.map(name => { return Object.assign(this.lstatSync(ppath.join(p, name)), { name, - path: undefined, + path: p, }); }); } else {