@yarnpkg/fslib
Advanced tools
Comparing version 2.10.3 to 2.10.4
@@ -13,3 +13,3 @@ "use strict"; | ||
LinkStrategy["ReadOnly"] = "readOnly"; | ||
})(LinkStrategy = exports.LinkStrategy || (exports.LinkStrategy = {})); | ||
})(LinkStrategy || (exports.LinkStrategy = LinkStrategy = {})); | ||
async function copyPromise(destinationFs, destination, sourceFs, source, opts) { | ||
@@ -16,0 +16,0 @@ const normalizedDestination = destinationFs.pathUtils.normalize(destination); |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
@@ -41,3 +40,3 @@ import { BigIntStats, Stats } from 'fs'; | ||
*/ | ||
makeInterval(opts: ListenerOptions): NodeJS.Timeout; | ||
makeInterval(opts: ListenerOptions): NodeJS.Timer; | ||
/** | ||
@@ -44,0 +43,0 @@ * Registers a listener and assigns it an interval. |
@@ -11,3 +11,3 @@ "use strict"; | ||
Event["Stop"] = "stop"; | ||
})(Event = exports.Event || (exports.Event = {})); | ||
})(Event || (exports.Event = Event = {})); | ||
var Status; | ||
@@ -18,3 +18,3 @@ (function (Status) { | ||
Status["Stopped"] = "stopped"; | ||
})(Status = exports.Status || (exports.Status = {})); | ||
})(Status || (exports.Status = Status = {})); | ||
function assertStatus(current, expected) { | ||
@@ -21,0 +21,0 @@ if (current !== expected) { |
@@ -5,3 +5,2 @@ /// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
@@ -13,2 +12,3 @@ import { Dirent as NodeDirent, ReadStream } from 'fs'; | ||
import { FSPath, Path, PortablePath, PathUtils, Filename } from './path'; | ||
export type BufferEncodingOrBuffer = BufferEncoding | 'buffer'; | ||
export type Stats = NodeStats & { | ||
@@ -37,7 +37,7 @@ crc?: number; | ||
export type CreateReadStreamOptions = Partial<{ | ||
encoding: string; | ||
encoding: BufferEncoding; | ||
fd: number; | ||
}>; | ||
export type CreateWriteStreamOptions = Partial<{ | ||
encoding: string; | ||
encoding: BufferEncoding; | ||
fd: number; | ||
@@ -56,11 +56,11 @@ flags: 'a'; | ||
export type WriteFileOptions = Partial<{ | ||
encoding: string; | ||
encoding: BufferEncoding; | ||
mode: number; | ||
flag: string; | ||
}> | string; | ||
}> | BufferEncoding; | ||
export type WatchOptions = Partial<{ | ||
persistent: boolean; | ||
recursive: boolean; | ||
encoding: string; | ||
}> | string; | ||
encoding: BufferEncodingOrBuffer; | ||
}> | BufferEncodingOrBuffer; | ||
export type WatchFileOptions = Partial<{ | ||
@@ -177,3 +177,3 @@ bigint: boolean; | ||
abstract fstatPromise(fd: number, opts?: { | ||
bigint: boolean; | ||
bigint?: boolean; | ||
}): Promise<BigIntStats | Stats>; | ||
@@ -185,3 +185,3 @@ abstract fstatSync(fd: number): Stats; | ||
abstract fstatSync(fd: number, opts?: { | ||
bigint: boolean; | ||
bigint?: boolean; | ||
}): BigIntStats | Stats; | ||
@@ -236,6 +236,6 @@ abstract lstatPromise(p: P): Promise<Stats>; | ||
abstract copyFileSync(sourceP: P, destP: P, flags?: number): void; | ||
abstract appendFilePromise(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
abstract appendFileSync(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
abstract writeFilePromise(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
abstract writeFileSync(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
abstract appendFilePromise(p: FSPath<P>, content: string | Uint8Array, opts?: WriteFileOptions): Promise<void>; | ||
abstract appendFileSync(p: FSPath<P>, content: string | Uint8Array, opts?: WriteFileOptions): void; | ||
abstract writeFilePromise(p: FSPath<P>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): Promise<void>; | ||
abstract writeFileSync(p: FSPath<P>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): void; | ||
abstract unlinkPromise(p: P): Promise<void>; | ||
@@ -247,6 +247,8 @@ abstract unlinkSync(p: P): void; | ||
lutimesSync?(p: P, atime: Date | string | number, mtime: Date | string | number): void; | ||
abstract readFilePromise(p: FSPath<P>, encoding: 'utf8'): Promise<string>; | ||
abstract readFilePromise(p: FSPath<P>, encoding?: string): Promise<Buffer>; | ||
abstract readFileSync(p: FSPath<P>, encoding: 'utf8'): string; | ||
abstract readFileSync(p: FSPath<P>, encoding?: string): Buffer; | ||
abstract readFilePromise(p: FSPath<P>, encoding?: null): Promise<Buffer>; | ||
abstract readFilePromise(p: FSPath<P>, encoding: BufferEncoding): Promise<string>; | ||
abstract readFilePromise(p: FSPath<P>, encoding?: BufferEncoding | null): Promise<Buffer | string>; | ||
abstract readFileSync(p: FSPath<P>, encoding?: null): Buffer; | ||
abstract readFileSync(p: FSPath<P>, encoding: BufferEncoding): string; | ||
abstract readFileSync(p: FSPath<P>, encoding?: BufferEncoding | null): Buffer | string; | ||
abstract readlinkPromise(p: P): Promise<P>; | ||
@@ -253,0 +255,0 @@ abstract readlinkSync(p: P): P; |
@@ -8,2 +8,3 @@ import * as constants from './constants'; | ||
export { normalizeLineEndings } from './FakeFS'; | ||
export type { BufferEncodingOrBuffer } from './FakeFS'; | ||
export type { CreateReadStreamOptions } from './FakeFS'; | ||
@@ -10,0 +11,0 @@ export type { CreateWriteStreamOptions } from './FakeFS'; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import fs, { BigIntStats, Stats } from 'fs'; | ||
@@ -115,6 +114,6 @@ import { CreateReadStreamOptions, CreateWriteStreamOptions, Dir, StatWatcher, WatchFileCallback, WatchFileOptions, OpendirOptions } from './FakeFS'; | ||
copyFileSync(sourceP: PortablePath, destP: PortablePath, flags?: number): void; | ||
appendFilePromise(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
appendFileSync(p: PortablePath, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
writeFilePromise(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
writeFileSync(p: PortablePath, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
appendFilePromise(p: FSPath<PortablePath>, content: string | Uint8Array, opts?: WriteFileOptions): Promise<void>; | ||
appendFileSync(p: PortablePath, content: string | Uint8Array, opts?: WriteFileOptions): void; | ||
writeFilePromise(p: FSPath<PortablePath>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): Promise<void>; | ||
writeFileSync(p: PortablePath, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): void; | ||
unlinkPromise(p: PortablePath): Promise<void>; | ||
@@ -134,6 +133,8 @@ unlinkSync(p: PortablePath): void; | ||
symlinkSync(target: PortablePath, p: PortablePath, type?: SymlinkType): void; | ||
readFilePromise(p: FSPath<PortablePath>, encoding: 'utf8'): Promise<string>; | ||
readFilePromise(p: FSPath<PortablePath>, encoding?: string): Promise<Buffer>; | ||
readFileSync(p: FSPath<PortablePath>, encoding: 'utf8'): string; | ||
readFileSync(p: FSPath<PortablePath>, encoding?: string): Buffer; | ||
readFilePromise(p: FSPath<PortablePath>, encoding?: null): Promise<Buffer>; | ||
readFilePromise(p: FSPath<PortablePath>, encoding: BufferEncoding): Promise<string>; | ||
readFilePromise(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Promise<Buffer | string>; | ||
readFileSync(p: FSPath<PortablePath>, encoding?: null): Buffer; | ||
readFileSync(p: FSPath<PortablePath>, encoding: BufferEncoding): string; | ||
readFileSync(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Buffer | string; | ||
readdirPromise(p: PortablePath): Promise<Array<Filename>>; | ||
@@ -140,0 +141,0 @@ readdirPromise(p: PortablePath, opts: { |
@@ -13,3 +13,2 @@ "use strict"; | ||
this.realFs = realFs; | ||
// @ts-expect-error | ||
if (typeof this.realFs.lutimes !== `undefined`) { | ||
@@ -133,3 +132,2 @@ this.lutimesPromise = this.lutimesPromiseImpl; | ||
if (opts) { | ||
// @ts-expect-error The node types are out of date | ||
this.realFs.stat(path_1.npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); | ||
@@ -144,3 +142,2 @@ } | ||
if (opts) { | ||
// @ts-expect-error The node types are out of date | ||
return this.realFs.statSync(path_1.npath.fromPortablePath(p), opts); | ||
@@ -155,3 +152,2 @@ } | ||
if (opts) { | ||
// @ts-expect-error - The node typings doesn't know about the options | ||
this.realFs.fstat(fd, opts, this.makeCallback(resolve, reject)); | ||
@@ -166,3 +162,2 @@ } | ||
if (opts) { | ||
// @ts-expect-error - The node typings doesn't know about the options | ||
return this.realFs.fstatSync(fd, opts); | ||
@@ -177,3 +172,2 @@ } | ||
if (opts) { | ||
// @ts-expect-error - TS does not know this takes options | ||
this.realFs.lstat(path_1.npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); | ||
@@ -188,3 +182,2 @@ } | ||
if (opts) { | ||
// @ts-expect-error - TS does not know this takes options | ||
return this.realFs.lstatSync(path_1.npath.fromPortablePath(p), opts); | ||
@@ -301,3 +294,2 @@ } | ||
async lutimesPromiseImpl(p, atime, mtime) { | ||
// @ts-expect-error: Not yet in DefinitelyTyped | ||
const lutimes = this.realFs.lutimes; | ||
@@ -311,3 +303,2 @@ if (typeof lutimes === `undefined`) | ||
lutimesSyncImpl(p, atime, mtime) { | ||
// @ts-expect-error: Not yet in DefinitelyTyped | ||
const lutimesSync = this.realFs.lutimesSync; | ||
@@ -320,3 +311,2 @@ if (typeof lutimesSync === `undefined`) | ||
return await new Promise((resolve, reject) => { | ||
// @ts-expect-error - Types are outdated, the second argument in the callback is either a string or undefined | ||
this.realFs.mkdir(path_1.npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); | ||
@@ -326,3 +316,2 @@ }); | ||
mkdirSync(p, opts) { | ||
// @ts-expect-error - Types are outdated, returns either a string or undefined | ||
return this.realFs.mkdirSync(path_1.npath.fromPortablePath(p), opts); | ||
@@ -329,0 +318,0 @@ } |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { URL } from 'url'; | ||
@@ -5,0 +4,0 @@ import { FakeFS } from './FakeFS'; |
@@ -216,3 +216,3 @@ "use strict"; | ||
} | ||
exports.NoFS = NoFS; | ||
NoFS.instance = new NoFS(); | ||
exports.NoFS = NoFS; |
@@ -5,3 +5,2 @@ /// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { BigIntStats, ReadStream, StatOptions, Stats, WriteStream, WriteVResult } from 'fs'; | ||
@@ -8,0 +7,0 @@ import type { CreateReadStreamOptions, CreateWriteStreamOptions, FakeFS } from '../FakeFS'; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import fs from 'fs'; | ||
@@ -4,0 +3,0 @@ import { FakeFS } from '../FakeFS'; |
@@ -208,40 +208,30 @@ "use strict"; | ||
// so we can just patch `fs.promises` and both will be updated | ||
const origEmitWarning = process.emitWarning; | ||
process.emitWarning = () => { }; | ||
let patchedFsPromises; | ||
try { | ||
patchedFsPromises = patchedFs.promises; | ||
} | ||
finally { | ||
process.emitWarning = origEmitWarning; | ||
} | ||
if (typeof patchedFsPromises !== `undefined`) { | ||
// `fs.promises.exists` doesn't exist | ||
for (const fnName of ASYNC_IMPLEMENTATIONS) { | ||
const origName = fnName.replace(/Promise$/, ``); | ||
if (typeof patchedFsPromises[origName] === `undefined`) | ||
continue; | ||
const fakeImpl = fakeFs[fnName]; | ||
if (typeof fakeImpl === `undefined`) | ||
continue; | ||
// Open is a bit particular with fs.promises: it returns a file handle | ||
// instance instead of the traditional file descriptor number | ||
if (fnName === `open`) | ||
continue; | ||
setupFn(patchedFsPromises, origName, (pathLike, ...args) => { | ||
if (pathLike instanceof FileHandle_1.FileHandle) { | ||
return pathLike[origName].apply(pathLike, args); | ||
} | ||
else { | ||
return fakeImpl.call(fakeFs, pathLike, ...args); | ||
} | ||
}); | ||
} | ||
setupFn(patchedFsPromises, `open`, async (...args) => { | ||
// @ts-expect-error | ||
const fd = await fakeFs.openPromise(...args); | ||
return new FileHandle_1.FileHandle(fd, fakeFs); | ||
const patchedFsPromises = patchedFs.promises; | ||
// `fs.promises.exists` doesn't exist | ||
for (const fnName of ASYNC_IMPLEMENTATIONS) { | ||
const origName = fnName.replace(/Promise$/, ``); | ||
if (typeof patchedFsPromises[origName] === `undefined`) | ||
continue; | ||
const fakeImpl = fakeFs[fnName]; | ||
if (typeof fakeImpl === `undefined`) | ||
continue; | ||
// Open is a bit particular with fs.promises: it returns a file handle | ||
// instance instead of the traditional file descriptor number | ||
if (fnName === `open`) | ||
continue; | ||
setupFn(patchedFsPromises, origName, (pathLike, ...args) => { | ||
if (pathLike instanceof FileHandle_1.FileHandle) { | ||
return pathLike[origName].apply(pathLike, args); | ||
} | ||
else { | ||
return fakeImpl.call(fakeFs, pathLike, ...args); | ||
} | ||
}); | ||
// `fs.promises.realpath` doesn't have a `native` property | ||
} | ||
setupFn(patchedFsPromises, `open`, async (...args) => { | ||
// @ts-expect-error | ||
const fd = await fakeFs.openPromise(...args); | ||
return new FileHandle_1.FileHandle(fd, fakeFs); | ||
}); | ||
// `fs.promises.realpath` doesn't have a `native` property | ||
} | ||
@@ -248,0 +238,0 @@ /** util.promisify implementations */ |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Stats, BigIntStats } from 'fs'; | ||
@@ -121,6 +120,6 @@ import { CreateReadStreamOptions, CreateWriteStreamOptions, FakeFS, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher, Dir, OpendirOptions } from './FakeFS'; | ||
copyFileSync(sourceP: P, destP: P, flags?: number): void; | ||
appendFilePromise(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
appendFileSync(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
writeFilePromise(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
writeFileSync(p: FSPath<P>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
appendFilePromise(p: FSPath<P>, content: string | Uint8Array, opts?: WriteFileOptions): Promise<void>; | ||
appendFileSync(p: FSPath<P>, content: string | Uint8Array, opts?: WriteFileOptions): void; | ||
writeFilePromise(p: FSPath<P>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): Promise<void>; | ||
writeFileSync(p: FSPath<P>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): void; | ||
unlinkPromise(p: P): Promise<void>; | ||
@@ -138,6 +137,8 @@ unlinkSync(p: P): void; | ||
symlinkSync(target: P, p: P, type?: SymlinkType): void; | ||
readFilePromise(p: FSPath<P>, encoding: 'utf8'): Promise<string>; | ||
readFilePromise(p: FSPath<P>, encoding?: string): Promise<Buffer>; | ||
readFileSync(p: FSPath<P>, encoding: 'utf8'): string; | ||
readFileSync(p: FSPath<P>, encoding?: string): Buffer; | ||
readFilePromise(p: FSPath<P>, encoding?: null): Promise<Buffer>; | ||
readFilePromise(p: FSPath<P>, encoding: BufferEncoding): Promise<string>; | ||
readFilePromise(p: FSPath<P>, encoding?: BufferEncoding | null): Promise<Buffer | string>; | ||
readFileSync(p: FSPath<P>, encoding?: null): Buffer; | ||
readFileSync(p: FSPath<P>, encoding: BufferEncoding): string; | ||
readFileSync(p: FSPath<P>, encoding?: BufferEncoding | null): Buffer | string; | ||
readdirPromise(p: P): Promise<Array<Filename>>; | ||
@@ -144,0 +145,0 @@ readdirPromise(p: P, opts: { |
@@ -192,18 +192,6 @@ "use strict"; | ||
async readFilePromise(p, encoding) { | ||
// This weird condition is required to tell TypeScript that the signatures are proper (otherwise it thinks that only the generic one is covered) | ||
if (encoding === `utf8`) { | ||
return this.baseFs.readFilePromise(this.fsMapToBase(p), encoding); | ||
} | ||
else { | ||
return this.baseFs.readFilePromise(this.fsMapToBase(p), encoding); | ||
} | ||
return this.baseFs.readFilePromise(this.fsMapToBase(p), encoding); | ||
} | ||
readFileSync(p, encoding) { | ||
// This weird condition is required to tell TypeScript that the signatures are proper (otherwise it thinks that only the generic one is covered) | ||
if (encoding === `utf8`) { | ||
return this.baseFs.readFileSync(this.fsMapToBase(p), encoding); | ||
} | ||
else { | ||
return this.baseFs.readFileSync(this.fsMapToBase(p), encoding); | ||
} | ||
return this.baseFs.readFileSync(this.fsMapToBase(p), encoding); | ||
} | ||
@@ -210,0 +198,0 @@ async readdirPromise(p, opts) { |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { BigIntStats, Stats } from 'fs'; | ||
@@ -4,0 +3,0 @@ import { Filename } from './path'; |
@@ -179,7 +179,7 @@ /// <reference types="node" /> | ||
private prepareCopyFile; | ||
appendFilePromise(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
appendFileSync(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
appendFilePromise(p: FSPath<PortablePath>, content: string | Uint8Array, opts?: WriteFileOptions): Promise<void>; | ||
appendFileSync(p: FSPath<PortablePath>, content: string | Uint8Array, opts?: WriteFileOptions): void; | ||
private fdToPath; | ||
writeFilePromise(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
writeFileSync(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
writeFilePromise(p: FSPath<PortablePath>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): Promise<void>; | ||
writeFileSync(p: FSPath<PortablePath>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): void; | ||
private prepareWriteFile; | ||
@@ -202,6 +202,8 @@ unlinkPromise(p: PortablePath): Promise<void>; | ||
symlinkSync(target: PortablePath, p: PortablePath): void; | ||
readFilePromise(p: FSPath<PortablePath>, encoding: 'utf8'): Promise<string>; | ||
readFilePromise(p: FSPath<PortablePath>, encoding?: string): Promise<Buffer>; | ||
readFileSync(p: FSPath<PortablePath>, encoding: 'utf8'): string; | ||
readFileSync(p: FSPath<PortablePath>, encoding?: string): Buffer; | ||
readFilePromise(p: FSPath<PortablePath>, encoding?: null): Promise<Buffer>; | ||
readFilePromise(p: FSPath<PortablePath>, encoding: BufferEncoding): Promise<string>; | ||
readFilePromise(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Promise<Buffer | string>; | ||
readFileSync(p: FSPath<PortablePath>, encoding?: null): Buffer; | ||
readFileSync(p: FSPath<PortablePath>, encoding: BufferEncoding): string; | ||
readFileSync(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Buffer | string; | ||
private readFileBuffer; | ||
@@ -208,0 +210,0 @@ readdirPromise(p: PortablePath): Promise<Array<Filename>>; |
@@ -351,2 +351,4 @@ "use strict"; | ||
path: p, | ||
// "This property is `true` if the underlying file has not been opened yet" | ||
pending: false, | ||
}); | ||
@@ -393,7 +395,9 @@ const immediate = setImmediate(async () => { | ||
}), { | ||
bytesWritten: 0, | ||
path: p, | ||
close() { | ||
stream.destroy(); | ||
}, | ||
bytesWritten: 0, | ||
path: p, | ||
// "This property is `true` if the underlying file has not been opened yet" | ||
pending: false, | ||
}); | ||
@@ -883,2 +887,3 @@ stream.on(`data`, chunk => { | ||
if (encoding !== null) | ||
// @ts-expect-error: toString ignores unneeded arguments | ||
content = content.toString(encoding); | ||
@@ -897,2 +902,3 @@ const newIndex = this.setFileSource(resolvedP, content); | ||
if (encoding !== null) | ||
// @ts-expect-error: toString ignores unneeded arguments | ||
content = content.toString(encoding); | ||
@@ -899,0 +905,0 @@ const newIndex = this.setFileSource(resolvedP, content); |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Libzip } from '@yarnpkg/libzip'; | ||
@@ -161,6 +160,6 @@ import { BigIntStats, Stats } from 'fs'; | ||
copyFileSync(sourceP: PortablePath, destP: PortablePath, flags?: number): void; | ||
appendFilePromise(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
appendFileSync(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
writeFilePromise(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): Promise<void>; | ||
writeFileSync(p: FSPath<PortablePath>, content: string | Buffer | ArrayBuffer | DataView, opts?: WriteFileOptions): void; | ||
appendFilePromise(p: FSPath<PortablePath>, content: string | Uint8Array, opts?: WriteFileOptions): Promise<void>; | ||
appendFileSync(p: FSPath<PortablePath>, content: string | Uint8Array, opts?: WriteFileOptions): void; | ||
writeFilePromise(p: FSPath<PortablePath>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): Promise<void>; | ||
writeFileSync(p: FSPath<PortablePath>, content: string | NodeJS.ArrayBufferView, opts?: WriteFileOptions): void; | ||
unlinkPromise(p: PortablePath): Promise<void>; | ||
@@ -178,6 +177,8 @@ unlinkSync(p: PortablePath): void; | ||
symlinkSync(target: PortablePath, p: PortablePath, type?: SymlinkType): void; | ||
readFilePromise(p: FSPath<PortablePath>, encoding: 'utf8'): Promise<string>; | ||
readFilePromise(p: FSPath<PortablePath>, encoding?: string): Promise<Buffer>; | ||
readFileSync(p: FSPath<PortablePath>, encoding: 'utf8'): string; | ||
readFileSync(p: FSPath<PortablePath>, encoding?: string): Buffer; | ||
readFilePromise(p: FSPath<PortablePath>, encoding?: null): Promise<Buffer>; | ||
readFilePromise(p: FSPath<PortablePath>, encoding: BufferEncoding): Promise<string>; | ||
readFilePromise(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Promise<Buffer | string>; | ||
readFileSync(p: FSPath<PortablePath>, encoding?: null): Buffer; | ||
readFileSync(p: FSPath<PortablePath>, encoding: BufferEncoding): string; | ||
readFileSync(p: FSPath<PortablePath>, encoding?: BufferEncoding | null): Buffer | string; | ||
readdirPromise(p: PortablePath): Promise<Array<Filename>>; | ||
@@ -184,0 +185,0 @@ readdirPromise(p: PortablePath, opts: { |
@@ -629,9 +629,3 @@ "use strict"; | ||
return this.makeCallPromise(p, async () => { | ||
// This weird switch is required to tell TypeScript that the signatures are proper (otherwise it thinks that only the generic one is covered) | ||
switch (encoding) { | ||
case `utf8`: | ||
return await this.baseFs.readFilePromise(p, encoding); | ||
default: | ||
return await this.baseFs.readFilePromise(p, encoding); | ||
} | ||
return await this.baseFs.readFilePromise(p, encoding); | ||
}, async (zipFs, { subPath }) => { | ||
@@ -643,9 +637,3 @@ return await zipFs.readFilePromise(subPath, encoding); | ||
return this.makeCallSync(p, () => { | ||
// This weird switch is required to tell TypeScript that the signatures are proper (otherwise it thinks that only the generic one is covered) | ||
switch (encoding) { | ||
case `utf8`: | ||
return this.baseFs.readFileSync(p, encoding); | ||
default: | ||
return this.baseFs.readFileSync(p, encoding); | ||
} | ||
return this.baseFs.readFileSync(p, encoding); | ||
}, (zipFs, { subPath }) => { | ||
@@ -652,0 +640,0 @@ return zipFs.readFileSync(subPath, encoding); |
{ | ||
"name": "@yarnpkg/fslib", | ||
"version": "2.10.3", | ||
"version": "2.10.4", | ||
"license": "BSD-2-Clause", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
275862
7039