Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yarnpkg/fslib

Package Overview
Dependencies
Maintainers
6
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/fslib - npm Package Compare versions

Comparing version 2.6.2 to 2.7.0

lib/patchFs/FileHandle.d.ts

76

lib/FakeFS.d.ts

@@ -85,2 +85,8 @@ /// <reference types="node" />

export declare type SymlinkType = 'file' | 'dir' | 'junction';
export interface StatOptions {
bigint?: boolean | undefined;
}
export interface StatSyncOptions extends StatOptions {
throwIfNoEntry?: boolean | undefined;
}
export declare abstract class FakeFS<P extends Path> {

@@ -136,15 +142,29 @@ readonly pathUtils: PathUtils<P>;

abstract statPromise(p: P): Promise<Stats>;
abstract statPromise(p: P, opts: {
abstract statPromise(p: P, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
abstract statPromise(p: P, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
abstract statPromise(p: P, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
abstract statPromise(p: P, opts?: StatOptions): Promise<Stats | BigIntStats>;
abstract statSync(p: P): Stats;
abstract statSync(p: P, opts: {
abstract statSync(p: P, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
abstract statSync(p: P, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
abstract statSync(p: P, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
abstract statSync(p: P, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
abstract statSync(p: P, opts?: {
abstract statSync(p: P, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
abstract statSync(p: P, opts?: StatSyncOptions): Stats | BigIntStats | undefined;
abstract fstatPromise(fd: number): Promise<Stats>;

@@ -165,21 +185,37 @@ abstract fstatPromise(fd: number, opts: {

abstract lstatPromise(p: P): Promise<Stats>;
abstract lstatPromise(p: P, opts: {
abstract lstatPromise(p: P, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
abstract lstatPromise(p: P, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
abstract lstatPromise(p: P, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
abstract lstatPromise(p: P, opts?: StatOptions): Promise<Stats | BigIntStats>;
abstract lstatSync(p: P): Stats;
abstract lstatSync(p: P, opts: {
abstract lstatSync(p: P, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
abstract lstatSync(p: P, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
abstract lstatSync(p: P, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
abstract lstatSync(p: P, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
abstract lstatSync(p: P, opts?: {
abstract lstatSync(p: P, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
abstract lstatSync(p: P, opts?: StatSyncOptions): Stats | BigIntStats | undefined;
abstract chmodPromise(p: P, mask: number): Promise<void>;
abstract chmodSync(p: P, mask: number): void;
abstract fchmodPromise(fd: number, mask: number): Promise<void>;
abstract fchmodSync(fd: number, mask: number): void;
abstract chownPromise(p: P, uid: number, gid: number): Promise<void>;
abstract chownSync(p: P, uid: number, gid: number): void;
abstract mkdirPromise(p: P, opts?: MkdirOptions): Promise<void>;
abstract mkdirSync(p: P, opts?: MkdirOptions): void;
abstract mkdirPromise(p: P, opts?: MkdirOptions): Promise<string | undefined>;
abstract mkdirSync(p: P, opts?: MkdirOptions): string | undefined;
abstract rmdirPromise(p: P, opts?: RmdirOptions): Promise<void>;

@@ -211,2 +247,4 @@ abstract rmdirSync(p: P, opts?: RmdirOptions): void;

abstract readlinkSync(p: P): P;
abstract ftruncatePromise(fd: number, len?: number): Promise<void>;
abstract ftruncateSync(fd: number, len?: number): void;
abstract truncatePromise(p: P, len?: number): Promise<void>;

@@ -221,3 +259,3 @@ abstract truncateSync(p: P, len?: number): void;

stableSort?: boolean;
}): AsyncGenerator<NonNullable<P>, void, unknown>;
}): AsyncGenerator<P, void, unknown>;
removePromise(p: P, { recursive, maxRetries }?: {

@@ -233,7 +271,7 @@ recursive?: boolean;

utimes?: [Date | string | number, Date | string | number];
}): Promise<void>;
}): Promise<string | undefined>;
mkdirpSync(p: P, { chmod, utimes }?: {
chmod?: number;
utimes?: [Date | string | number, Date | string | number];
}): void;
}): string | undefined;
copyPromise(destination: P, source: P, options?: {

@@ -240,0 +278,0 @@ baseFs?: undefined;

@@ -98,4 +98,5 @@ "use strict";

if (p === this.pathUtils.dirname(p))
return;
return undefined;
const parts = p.split(this.pathUtils.sep);
let createdDirectory;
for (let u = 2; u <= parts.length; ++u) {

@@ -115,2 +116,3 @@ const subPath = parts.slice(0, u).join(this.pathUtils.sep);

}
createdDirectory !== null && createdDirectory !== void 0 ? createdDirectory : (createdDirectory = subPath);
if (chmod != null)

@@ -127,2 +129,3 @@ await this.chmodPromise(subPath, chmod);

}
return createdDirectory;
}

@@ -132,4 +135,5 @@ mkdirpSync(p, { chmod, utimes } = {}) {

if (p === this.pathUtils.dirname(p))
return;
return undefined;
const parts = p.split(this.pathUtils.sep);
let createdDirectory;
for (let u = 2; u <= parts.length; ++u) {

@@ -149,2 +153,3 @@ const subPath = parts.slice(0, u).join(this.pathUtils.sep);

}
createdDirectory !== null && createdDirectory !== void 0 ? createdDirectory : (createdDirectory = subPath);
if (chmod != null)

@@ -161,2 +166,3 @@ this.chmodSync(subPath, chmod);

}
return createdDirectory;
}

@@ -163,0 +169,0 @@ async copyPromise(destination, source, { baseFs = this, overwrite = true, stableSort = false, stableTime = false, linkStrategy = null } = {}) {

@@ -41,4 +41,4 @@ import * as constants from './constants';

export { ZipOpenFS } from './ZipOpenFS';
export { patchFs, extendFs } from './patchFs';
export { patchFs, extendFs } from './patchFs/patchFs';
export { xfs } from './xfs';
export type { XFS } from './xfs';

@@ -48,3 +48,3 @@ "use strict";

Object.defineProperty(exports, "ZipOpenFS", { enumerable: true, get: function () { return ZipOpenFS_1.ZipOpenFS; } });
var patchFs_1 = require("./patchFs");
var patchFs_1 = require("./patchFs/patchFs");
Object.defineProperty(exports, "patchFs", { enumerable: true, get: function () { return patchFs_1.patchFs; } });

@@ -51,0 +51,0 @@ Object.defineProperty(exports, "extendFs", { enumerable: true, get: function () { return patchFs_1.extendFs; } });

@@ -7,3 +7,3 @@ /// <reference types="node" />

import { CreateReadStreamOptions, CreateWriteStreamOptions, Dir, StatWatcher, WatchFileCallback, WatchFileOptions, OpendirOptions } from './FakeFS';
import { Dirent, SymlinkType } from './FakeFS';
import { Dirent, SymlinkType, StatSyncOptions, StatOptions } from './FakeFS';
import { BasePortableFakeFS, WriteFileOptions } from './FakeFS';

@@ -39,15 +39,27 @@ import { MkdirOptions, RmdirOptions, WatchOptions, WatchCallback, Watcher } from './FakeFS';

statPromise(p: PortablePath): Promise<Stats>;
statPromise(p: PortablePath, opts: {
statPromise(p: PortablePath, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
statPromise(p: PortablePath, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
statPromise(p: PortablePath, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
statSync(p: PortablePath): Stats;
statSync(p: PortablePath, opts: {
statSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
statSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
statSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
statSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
statSync(p: PortablePath, opts?: {
statSync(p: PortablePath, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
fstatPromise(fd: number): Promise<Stats>;

@@ -68,15 +80,29 @@ fstatPromise(fd: number, opts: {

lstatPromise(p: PortablePath): Promise<Stats>;
lstatPromise(p: PortablePath, opts: {
lstatPromise(p: PortablePath, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
lstatPromise(p: PortablePath, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
lstatPromise(p: PortablePath, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
lstatSync(p: PortablePath): Stats;
lstatSync(p: PortablePath, opts: {
lstatSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
lstatSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
lstatSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
lstatSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
lstatSync(p: PortablePath, opts?: {
lstatSync(p: PortablePath, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
fchmodPromise(fd: number, mask: number): Promise<void>;
fchmodSync(fd: number, mask: number): void;
chmodPromise(p: PortablePath, mask: number): Promise<void>;

@@ -100,4 +126,4 @@ chmodSync(p: PortablePath, mask: number): void;

private lutimesSyncImpl;
mkdirPromise(p: PortablePath, opts?: MkdirOptions): Promise<void>;
mkdirSync(p: PortablePath, opts?: MkdirOptions): void;
mkdirPromise(p: PortablePath, opts?: MkdirOptions): Promise<string | undefined>;
mkdirSync(p: PortablePath, opts?: MkdirOptions): string | undefined;
rmdirPromise(p: PortablePath, opts?: RmdirOptions): Promise<void>;

@@ -137,2 +163,4 @@ rmdirSync(p: PortablePath, opts?: RmdirOptions): void;

truncateSync(p: PortablePath, len?: number): void;
ftruncatePromise(fd: number, len?: number): Promise<void>;
ftruncateSync(fd: number, len?: number): void;
watch(p: PortablePath, cb?: WatchCallback): Watcher;

@@ -139,0 +167,0 @@ watch(p: PortablePath, opts: WatchOptions, cb?: WatchCallback): Watcher;

@@ -132,2 +132,3 @@ "use strict";

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));

@@ -142,2 +143,3 @@ }

if (opts) {
// @ts-expect-error The node types are out of date
return this.realFs.statSync(path_1.npath.fromPortablePath(p), opts);

@@ -189,2 +191,10 @@ }

}
async fchmodPromise(fd, mask) {
return await new Promise((resolve, reject) => {
this.realFs.fchmod(fd, mask, this.makeCallback(resolve, reject));
});
}
fchmodSync(fd, mask) {
return this.realFs.fchmodSync(fd, mask);
}
async chmodPromise(p, mask) {

@@ -296,2 +306,3 @@ return await new Promise((resolve, reject) => {

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));

@@ -301,2 +312,3 @@ });

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);

@@ -380,2 +392,10 @@ }

}
async ftruncatePromise(fd, len) {
return await new Promise((resolve, reject) => {
this.realFs.ftruncate(fd, len, this.makeCallback(resolve, reject));
});
}
ftruncateSync(fd, len) {
return this.realFs.ftruncateSync(fd, len);
}
watch(p, a, b) {

@@ -382,0 +402,0 @@ return this.realFs.watch(path_1.npath.fromPortablePath(p),

@@ -35,2 +35,4 @@ import { FakeFS } from './FakeFS';

lstatSync(p: PortablePath): never;
fchmodPromise(): Promise<never>;
fchmodSync(): never;
chmodPromise(): Promise<never>;

@@ -66,2 +68,4 @@ chmodSync(): never;

truncateSync(): never;
ftruncatePromise(fd: number, len?: number): Promise<never>;
ftruncateSync(fd: number, len?: number): never;
watch(): never;

@@ -68,0 +72,0 @@ watchFile(): never;

@@ -98,2 +98,8 @@ "use strict";

}
async fchmodPromise() {
throw makeError();
}
fchmodSync() {
throw makeError();
}
async chmodPromise() {

@@ -189,2 +195,8 @@ throw makeError();

}
async ftruncatePromise(fd, len) {
throw makeError();
}
ftruncateSync(fd, len) {
throw makeError();
}
watch() {

@@ -191,0 +203,0 @@ throw makeError();

@@ -7,3 +7,3 @@ /// <reference types="node" />

import { CreateReadStreamOptions, CreateWriteStreamOptions, FakeFS, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher, Dir, OpendirOptions } from './FakeFS';
import { Dirent, SymlinkType } from './FakeFS';
import { Dirent, SymlinkType, StatSyncOptions, StatOptions } from './FakeFS';
import { MkdirOptions, RmdirOptions, WriteFileOptions, WatchCallback, WatchOptions, Watcher } from './FakeFS';

@@ -45,15 +45,27 @@ import { FSPath, Filename, Path } from './path';

statPromise(p: P): Promise<Stats>;
statPromise(p: P, opts: {
statPromise(p: P, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
statPromise(p: P, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
statPromise(p: P, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
statSync(p: P): Stats;
statSync(p: P, opts: {
statSync(p: P, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
statSync(p: P, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
statSync(p: P, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
statSync(p: P, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
statSync(p: P, opts?: {
statSync(p: P, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
fstatPromise(fd: number): Promise<Stats>;

@@ -74,15 +86,29 @@ fstatPromise(fd: number, opts: {

lstatPromise(p: P): Promise<Stats>;
lstatPromise(p: P, opts: {
lstatPromise(p: P, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
lstatPromise(p: P, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
lstatPromise(p: P, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
lstatSync(p: P): Stats;
lstatSync(p: P, opts: {
lstatSync(p: P, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
lstatSync(p: P, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
lstatSync(p: P, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
lstatSync(p: P, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
lstatSync(p: P, opts?: {
lstatSync(p: P, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
fchmodPromise(fd: number, mask: number): Promise<void>;
fchmodSync(fd: number, mask: number): void;
chmodPromise(p: P, mask: number): Promise<void>;

@@ -104,4 +130,4 @@ chmodSync(p: P, mask: number): void;

utimesSync(p: P, atime: Date | string | number, mtime: Date | string | number): void;
mkdirPromise(p: P, opts?: MkdirOptions): Promise<void>;
mkdirSync(p: P, opts?: MkdirOptions): void;
mkdirPromise(p: P, opts?: MkdirOptions): Promise<string | undefined>;
mkdirSync(p: P, opts?: MkdirOptions): string | undefined;
rmdirPromise(p: P, opts?: RmdirOptions): Promise<void>;

@@ -141,2 +167,4 @@ rmdirSync(p: P, opts?: RmdirOptions): void;

truncateSync(p: P, len?: number): void;
ftruncatePromise(fd: number, len?: number): Promise<void>;
ftruncateSync(fd: number, len?: number): void;
watch(p: P, cb?: WatchCallback): Watcher;

@@ -143,0 +171,0 @@ watch(p: P, opts: WatchOptions, cb?: WatchCallback): Watcher;

@@ -91,3 +91,3 @@ "use strict";

}
async lstatPromise(p, opts) {
lstatPromise(p, opts) {
return this.baseFs.lstatPromise(this.mapToBase(p), opts);

@@ -98,2 +98,8 @@ }

}
async fchmodPromise(fd, mask) {
return this.baseFs.fchmodPromise(fd, mask);
}
fchmodSync(fd, mask) {
return this.baseFs.fchmodSync(fd, mask);
}
async chmodPromise(p, mask) {

@@ -217,2 +223,8 @@ return this.baseFs.chmodPromise(this.mapToBase(p), mask);

}
async ftruncatePromise(fd, len) {
return this.baseFs.ftruncatePromise(fd, len);
}
ftruncateSync(fd, len) {
return this.baseFs.ftruncateSync(fd, len);
}
watch(p, a, b) {

@@ -219,0 +231,0 @@ return this.baseFs.watch(this.mapToBase(p),

@@ -6,3 +6,3 @@ /// <reference types="node" />

import { ReadStream, WriteStream } from 'fs';
import { WatchOptions, WatchCallback, Watcher, Dir, Stats, BigIntStats } from './FakeFS';
import { WatchOptions, WatchCallback, Watcher, Dir, Stats, BigIntStats, StatSyncOptions, StatOptions } from './FakeFS';
import { FakeFS, MkdirOptions, RmdirOptions, WriteFileOptions, OpendirOptions } from './FakeFS';

@@ -84,15 +84,29 @@ import { CreateReadStreamOptions, CreateWriteStreamOptions, BasePortableFakeFS, ExtractHintOptions, WatchFileCallback, WatchFileOptions, StatWatcher } from './FakeFS';

statPromise(p: PortablePath): Promise<Stats>;
statPromise(p: PortablePath, opts: {
statPromise(p: PortablePath, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
statPromise(p: PortablePath, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
statPromise(p: PortablePath, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
statPromise(p: PortablePath, opts?: StatOptions): Promise<Stats | BigIntStats>;
statSync(p: PortablePath): Stats;
statSync(p: PortablePath, opts: {
statSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
statSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
statSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
statSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
statSync(p: PortablePath, opts?: {
statSync(p: PortablePath, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
statSync(p: PortablePath, opts?: StatSyncOptions): Stats | BigIntStats | undefined;
fstatPromise(fd: number): Promise<Stats>;

@@ -113,15 +127,29 @@ fstatPromise(fd: number, opts: {

lstatPromise(p: PortablePath): Promise<Stats>;
lstatPromise(p: PortablePath, opts: {
lstatPromise(p: PortablePath, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
lstatPromise(p: PortablePath, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
lstatPromise(p: PortablePath, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
lstatPromise(p: PortablePath, opts?: StatOptions): Promise<Stats | BigIntStats>;
lstatSync(p: PortablePath): Stats;
lstatSync(p: PortablePath, opts: {
lstatSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
lstatSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
lstatSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
lstatSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
lstatSync(p: PortablePath, opts?: {
lstatSync(p: PortablePath, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
lstatSync(p: PortablePath, opts?: StatSyncOptions): Stats | BigIntStats | undefined;
private statImpl;

@@ -141,2 +169,4 @@ private getUnixMode;

private getFileSource;
fchmodPromise(fd: number, mask: number): Promise<void>;
fchmodSync(fd: number, mask: number): void;
chmodPromise(p: PortablePath, mask: number): Promise<void>;

@@ -164,4 +194,4 @@ chmodSync(p: PortablePath, mask: number): void;

private utimesImpl;
mkdirPromise(p: PortablePath, opts?: MkdirOptions): Promise<void>;
mkdirSync(p: PortablePath, { mode, recursive }?: MkdirOptions): void;
mkdirPromise(p: PortablePath, opts?: MkdirOptions): Promise<string | undefined>;
mkdirSync(p: PortablePath, { mode, recursive }?: MkdirOptions): string | undefined;
rmdirPromise(p: PortablePath, opts?: RmdirOptions): Promise<void>;

@@ -204,2 +234,4 @@ rmdirSync(p: PortablePath, { recursive }?: RmdirOptions): void;

truncateSync(p: PortablePath, len?: number): void;
ftruncatePromise(fd: number, len?: number): Promise<void>;
ftruncateSync(fd: number, len?: number): void;
watch(p: PortablePath, cb?: WatchCallback): Watcher;

@@ -206,0 +238,0 @@ watch(p: PortablePath, opts: WatchOptions, cb?: WatchCallback): Watcher;

@@ -421,3 +421,3 @@ "use strict";

try {
resolvedP = this.resolveFilename(`stat '${p}'`, p);
resolvedP = this.resolveFilename(`stat '${p}'`, p, undefined, false);
}

@@ -427,2 +427,4 @@ catch (error) {

}
if (resolvedP === undefined)
return false;
return this.entries.has(resolvedP) || this.listings.has(resolvedP);

@@ -441,9 +443,16 @@ }

}
async statPromise(p, opts) {
return this.statSync(p, opts);
async statPromise(p, opts = { bigint: false }) {
if (opts.bigint)
return this.statSync(p, { bigint: true });
return this.statSync(p);
}
statSync(p, opts) {
const resolvedP = this.resolveFilename(`stat '${p}'`, p);
if (!this.entries.has(resolvedP) && !this.listings.has(resolvedP))
statSync(p, opts = { bigint: false, throwIfNoEntry: true }) {
const resolvedP = this.resolveFilename(`stat '${p}'`, p, undefined, opts.throwIfNoEntry);
if (resolvedP === undefined)
return undefined;
if (!this.entries.has(resolvedP) && !this.listings.has(resolvedP)) {
if (opts.throwIfNoEntry === false)
return undefined;
throw errors.ENOENT(`stat '${p}'`);
}
if (p[p.length - 1] === `/` && !this.listings.has(resolvedP))

@@ -468,9 +477,16 @@ throw errors.ENOTDIR(`stat '${p}'`);

}
async lstatPromise(p, opts) {
return this.lstatSync(p, opts);
async lstatPromise(p, opts = { bigint: false }) {
if (opts.bigint)
return this.lstatSync(p, { bigint: true });
return this.lstatSync(p);
}
lstatSync(p, opts) {
const resolvedP = this.resolveFilename(`lstat '${p}'`, p, false);
if (!this.entries.has(resolvedP) && !this.listings.has(resolvedP))
lstatSync(p, opts = { bigint: false, throwIfNoEntry: true }) {
const resolvedP = this.resolveFilename(`lstat '${p}'`, p, false, opts.throwIfNoEntry);
if (resolvedP === undefined)
return undefined;
if (!this.entries.has(resolvedP) && !this.listings.has(resolvedP)) {
if (opts.throwIfNoEntry === false)
return undefined;
throw errors.ENOENT(`lstat '${p}'`);
}
if (p[p.length - 1] === `/` && !this.listings.has(resolvedP))

@@ -583,3 +599,3 @@ throw errors.ENOTDIR(`lstat '${p}'`);

}
resolveFilename(reason, p, resolveLastComponent = true) {
resolveFilename(reason, p, resolveLastComponent = true, throwIfNoEntry = true) {
if (!this.ready)

@@ -594,3 +610,3 @@ throw errors.EBUSY(`archive closed, ${reason}`);

const target = this.getFileSource(fileIndex).toString();
return this.resolveFilename(reason, path_1.ppath.resolve(path_1.ppath.dirname(resolvedP), target), true);
return this.resolveFilename(reason, path_1.ppath.resolve(path_1.ppath.dirname(resolvedP), target), true, throwIfNoEntry);
}

@@ -602,7 +618,12 @@ else {

while (true) {
const parentP = this.resolveFilename(reason, path_1.ppath.dirname(resolvedP), true);
const parentP = this.resolveFilename(reason, path_1.ppath.dirname(resolvedP), true, throwIfNoEntry);
if (parentP === undefined)
return parentP;
const isDir = this.listings.has(parentP);
const doesExist = this.entries.has(parentP);
if (!isDir && !doesExist)
if (!isDir && !doesExist) {
if (throwIfNoEntry === false)
return undefined;
throw errors.ENOENT(reason);
}
if (!isDir)

@@ -750,2 +771,8 @@ throw errors.ENOTDIR(reason);

}
async fchmodPromise(fd, mask) {
return this.chmodPromise(this.fdToPath(fd, `fchmod`), mask);
}
fchmodSync(fd, mask) {
return this.chmodSync(this.fdToPath(fd, `fchmodSync`), mask);
}
async chmodPromise(p, mask) {

@@ -946,6 +973,4 @@ return this.chmodSync(p, mask);

mkdirSync(p, { mode = 0o755, recursive = false } = {}) {
if (recursive) {
this.mkdirpSync(p, { chmod: mode });
return;
}
if (recursive)
return this.mkdirpSync(p, { chmod: mode });
if (this.readOnly)

@@ -958,2 +983,3 @@ throw errors.EROFS(`mkdir '${p}'`);

this.chmodSync(resolvedP, mode);
return undefined;
}

@@ -1110,2 +1136,8 @@ async rmdirPromise(p, opts) {

}
async ftruncatePromise(fd, len) {
return this.truncatePromise(this.fdToPath(fd, `ftruncate`), len);
}
ftruncateSync(fd, len) {
return this.truncateSync(this.fdToPath(fd, `ftruncateSync`), len);
}
watch(p, a, b) {

@@ -1112,0 +1144,0 @@ let persistent;

@@ -7,3 +7,3 @@ /// <reference types="node" />

import { BigIntStats, Stats } from 'fs';
import { WatchOptions, WatchCallback, Watcher } from './FakeFS';
import { WatchOptions, WatchCallback, Watcher, StatOptions, StatSyncOptions } from './FakeFS';
import { FakeFS, MkdirOptions, RmdirOptions, WriteFileOptions, OpendirOptions } from './FakeFS';

@@ -84,15 +84,28 @@ import { Dirent, SymlinkType } from './FakeFS';

statPromise(p: PortablePath): Promise<Stats>;
statPromise(p: PortablePath, opts: {
statPromise(p: PortablePath, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
statPromise(p: PortablePath, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
statPromise(p: PortablePath, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
statPromise(p: PortablePath, opts?: StatOptions): Promise<Stats | BigIntStats>;
statSync(p: PortablePath): Stats;
statSync(p: PortablePath, opts: {
statSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
statSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
statSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
statSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
statSync(p: PortablePath, opts?: {
statSync(p: PortablePath, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
fstatPromise(fd: number): Promise<Stats>;

@@ -113,15 +126,29 @@ fstatPromise(fd: number, opts: {

lstatPromise(p: PortablePath): Promise<Stats>;
lstatPromise(p: PortablePath, opts: {
lstatPromise(p: PortablePath, opts: (StatOptions & {
bigint?: false | undefined;
}) | undefined): Promise<Stats>;
lstatPromise(p: PortablePath, opts: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
lstatPromise(p: PortablePath, opts?: {
bigint: boolean;
}): Promise<BigIntStats | Stats>;
lstatSync(p: PortablePath): Stats;
lstatSync(p: PortablePath, opts: {
lstatSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
throwIfNoEntry: false;
}): Stats | undefined;
lstatSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
throwIfNoEntry: false;
}): BigIntStats | undefined;
lstatSync(p: PortablePath, opts?: StatSyncOptions & {
bigint?: false | undefined;
}): Stats;
lstatSync(p: PortablePath, opts: StatSyncOptions & {
bigint: true;
}): BigIntStats;
lstatSync(p: PortablePath, opts?: {
lstatSync(p: PortablePath, opts: StatSyncOptions & {
bigint: boolean;
}): BigIntStats | Stats;
throwIfNoEntry?: false | undefined;
}): Stats | BigIntStats;
fchmodPromise(fd: number, mask: number): Promise<void>;
fchmodSync(fd: number, mask: number): void;
chmodPromise(p: PortablePath, mask: number): Promise<void>;

@@ -143,4 +170,4 @@ chmodSync(p: PortablePath, mask: number): void;

utimesSync(p: PortablePath, atime: Date | string | number, mtime: Date | string | number): void;
mkdirPromise(p: PortablePath, opts?: MkdirOptions): Promise<void>;
mkdirSync(p: PortablePath, opts?: MkdirOptions): void;
mkdirPromise(p: PortablePath, opts?: MkdirOptions): Promise<string | undefined>;
mkdirSync(p: PortablePath, opts?: MkdirOptions): string | undefined;
rmdirPromise(p: PortablePath, opts?: RmdirOptions): Promise<void>;

@@ -180,2 +207,4 @@ rmdirSync(p: PortablePath, opts?: RmdirOptions): void;

truncateSync(p: PortablePath, len?: number): void;
ftruncatePromise(fd: number, len?: number): Promise<void>;
ftruncateSync(fd: number, len?: number): void;
watch(p: PortablePath, cb?: WatchCallback): Watcher;

@@ -182,0 +211,0 @@ watch(p: PortablePath, opts: WatchOptions, cb?: WatchCallback): Watcher;

@@ -335,2 +335,20 @@ "use strict";

}
async fchmodPromise(fd, mask) {
if ((fd & ZIP_FD) === 0)
return this.baseFs.fchmodPromise(fd, mask);
const entry = this.fdMap.get(fd);
if (typeof entry === `undefined`)
throw errors.EBADF(`fchmod`);
const [zipFs, realFd] = entry;
return zipFs.fchmodPromise(realFd, mask);
}
fchmodSync(fd, mask) {
if ((fd & ZIP_FD) === 0)
return this.baseFs.fchmodSync(fd, mask);
const entry = this.fdMap.get(fd);
if (typeof entry === `undefined`)
throw errors.EBADF(`fchmodSync`);
const [zipFs, realFd] = entry;
return zipFs.fchmodSync(realFd, mask);
}
async chmodPromise(p, mask) {

@@ -656,2 +674,20 @@ return await this.makeCallPromise(p, async () => {

}
async ftruncatePromise(fd, len) {
if ((fd & ZIP_FD) === 0)
return this.baseFs.ftruncatePromise(fd, len);
const entry = this.fdMap.get(fd);
if (typeof entry === `undefined`)
throw errors.EBADF(`ftruncate`);
const [zipFs, realFd] = entry;
return zipFs.ftruncatePromise(realFd, len);
}
ftruncateSync(fd, len) {
if ((fd & ZIP_FD) === 0)
return this.baseFs.ftruncateSync(fd, len);
const entry = this.fdMap.get(fd);
if (typeof entry === `undefined`)
throw errors.EBADF(`ftruncateSync`);
const [zipFs, realFd] = entry;
return zipFs.ftruncateSync(realFd, len);
}
watch(p, a, b) {

@@ -658,0 +694,0 @@ return this.makeCallSync(p, () => {

{
"name": "@yarnpkg/fslib",
"version": "2.6.2",
"version": "2.7.0",
"license": "BSD-2-Clause",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc