pwd-fs 3.4.0 → 3.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/powered-file-system/append.d.ts +9 -6
- package/dist/powered-file-system/append.js +4 -4
- package/dist/powered-file-system/chmod.d.ts +4 -4
- package/dist/powered-file-system/chmod.js +9 -10
- package/dist/powered-file-system/chown.d.ts +7 -4
- package/dist/powered-file-system/chown.js +18 -8
- package/dist/powered-file-system/copy.d.ts +10 -7
- package/dist/powered-file-system/copy.js +11 -12
- package/dist/powered-file-system/empty-dir.d.ts +4 -4
- package/dist/powered-file-system/empty-dir.js +9 -10
- package/dist/powered-file-system/mkdir.d.ts +9 -6
- package/dist/powered-file-system/mkdir.js +9 -10
- package/dist/powered-file-system/read.d.ts +10 -6
- package/dist/powered-file-system/read.js +9 -5
- package/dist/powered-file-system/readdir.d.ts +11 -6
- package/dist/powered-file-system/readdir.js +8 -6
- package/dist/powered-file-system/readlink.d.ts +9 -4
- package/dist/powered-file-system/readlink.js +8 -6
- package/dist/powered-file-system/realpath.d.ts +9 -4
- package/dist/powered-file-system/realpath.js +8 -6
- package/dist/powered-file-system/remove.d.ts +5 -5
- package/dist/powered-file-system/remove.js +11 -20
- package/dist/powered-file-system/rename.d.ts +5 -5
- package/dist/powered-file-system/rename.js +11 -7
- package/dist/powered-file-system/stat.d.ts +4 -4
- package/dist/powered-file-system/stat.js +8 -6
- package/dist/powered-file-system/symlink.d.ts +4 -4
- package/dist/powered-file-system/symlink.js +11 -4
- package/dist/powered-file-system/test.d.ts +10 -5
- package/dist/powered-file-system/test.js +8 -5
- package/dist/powered-file-system/write.d.ts +10 -7
- package/dist/powered-file-system/write.js +9 -6
- package/dist/powered-file-system.d.ts +103 -56
- package/dist/powered-file-system.js +5 -48
- package/dist/powered-file-system.test.js +25 -0
- package/dist/recurse-io-sync.d.ts +1 -1
- package/dist/recurse-io-sync.js +11 -25
- package/dist/recurse-io.d.ts +1 -1
- package/dist/recurse-io.js +31 -49
- package/dist/suite.test.js +1 -1
- package/package.json +12 -17
- package/readme.md +30 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoweredFileSystem } from './powered-file-system';
|
|
2
2
|
/**
|
|
3
|
-
* Default file system instance
|
|
3
|
+
* Default file system instance using the current working directory as its base.
|
|
4
4
|
*/
|
|
5
5
|
export declare const pfs: PoweredFileSystem;
|
|
6
6
|
export default PoweredFileSystem;
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.pfs = void 0;
|
|
18
18
|
const powered_file_system_1 = require("./powered-file-system");
|
|
19
19
|
/**
|
|
20
|
-
* Default file system instance
|
|
20
|
+
* Default file system instance using the current working directory as its base.
|
|
21
21
|
*/
|
|
22
22
|
exports.pfs = new powered_file_system_1.PoweredFileSystem();
|
|
23
23
|
exports.default = powered_file_system_1.PoweredFileSystem;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
|
+
type AppendOptions = {
|
|
3
|
+
encoding?: BufferEncoding | null;
|
|
4
|
+
umask?: number;
|
|
5
|
+
};
|
|
2
6
|
/**
|
|
3
7
|
* Backward-compatible append wrapper implemented on top of `write()`.
|
|
4
8
|
*/
|
|
5
|
-
export declare function append
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}): T extends true ? void : Promise<void>;
|
|
9
|
+
export declare function append(this: PoweredFileSystem, src: string, data: Buffer | string, options: SyncOption & AppendOptions): void;
|
|
10
|
+
export declare function append(this: PoweredFileSystem, src: string, data: Buffer | string, options?: AsyncOption & AppendOptions): Promise<void>;
|
|
11
|
+
export declare function append(this: PoweredFileSystem, src: string, data: Buffer | string, options?: MaybeSyncOption & AppendOptions): void | Promise<void>;
|
|
12
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.append = append;
|
|
4
|
-
/**
|
|
5
|
-
* Backward-compatible append wrapper implemented on top of `write()`.
|
|
6
|
-
*/
|
|
7
4
|
function append(src, data, options) {
|
|
8
5
|
const { sync = false, encoding = 'utf8', umask = 0o000 } = options ?? {};
|
|
9
|
-
|
|
6
|
+
if (sync) {
|
|
7
|
+
return this.write(src, data, { sync: true, encoding, umask, flag: 'a' });
|
|
8
|
+
}
|
|
9
|
+
return this.write(src, data, { encoding, umask, flag: 'a' });
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
2
|
/**
|
|
3
3
|
* Resolves the target path and delegates recursive mode updates.
|
|
4
4
|
*/
|
|
5
|
-
export declare function chmod
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export declare function chmod(this: PoweredFileSystem, src: string, mode: number, options: SyncOption): void;
|
|
6
|
+
export declare function chmod(this: PoweredFileSystem, src: string, mode: number, options?: AsyncOption): Promise<void>;
|
|
7
|
+
export declare function chmod(this: PoweredFileSystem, src: string, mode: number, options?: MaybeSyncOption): void | Promise<void>;
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.chmod = chmod;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
4
|
const recurse_io_1 = require("../recurse-io");
|
|
9
5
|
const recurse_io_sync_1 = require("../recurse-io-sync");
|
|
10
|
-
/**
|
|
11
|
-
* Resolves the target path and delegates recursive mode updates.
|
|
12
|
-
*/
|
|
13
6
|
function chmod(src, mode, options) {
|
|
14
7
|
const { sync = false } = options ?? {};
|
|
15
|
-
src = node_path_1.default.resolve(this.pwd, src);
|
|
16
8
|
if (sync) {
|
|
17
|
-
(0, recurse_io_sync_1.chmodSync)(src, mode);
|
|
18
|
-
return
|
|
9
|
+
(0, recurse_io_sync_1.chmodSync)(this.resolve(src), mode);
|
|
10
|
+
return;
|
|
19
11
|
}
|
|
20
12
|
return new Promise((resolve, reject) => {
|
|
13
|
+
try {
|
|
14
|
+
src = this.resolve(src);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
reject(err);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
21
20
|
(0, recurse_io_1.chmod)(src, mode, (err) => {
|
|
22
21
|
if (err) {
|
|
23
22
|
return reject(err);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
2
|
/**
|
|
3
3
|
* Resolves the target path and applies recursive ownership changes where supported.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
sync?: T;
|
|
5
|
+
type ChownOptions = {
|
|
7
6
|
uid?: number;
|
|
8
7
|
gid?: number;
|
|
9
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare function chown(this: PoweredFileSystem, src: string, options: SyncOption & ChownOptions): void;
|
|
10
|
+
export declare function chown(this: PoweredFileSystem, src: string, options?: AsyncOption & ChownOptions): Promise<void>;
|
|
11
|
+
export declare function chown(this: PoweredFileSystem, src: string, options?: MaybeSyncOption & ChownOptions): void | Promise<void>;
|
|
12
|
+
export {};
|
|
@@ -5,26 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.chown = chown;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
8
|
const recurse_io_1 = require("../recurse-io");
|
|
10
9
|
const recurse_io_sync_1 = require("../recurse-io-sync");
|
|
11
|
-
/**
|
|
12
|
-
* Resolves the target path and applies recursive ownership changes where supported.
|
|
13
|
-
*/
|
|
14
10
|
function chown(src, options) {
|
|
15
|
-
const { sync = false, uid
|
|
16
|
-
src = node_path_1.default.resolve(this.pwd, src);
|
|
11
|
+
const { sync = false, uid, gid } = options ?? {};
|
|
17
12
|
if (sync) {
|
|
13
|
+
src = this.resolve(src);
|
|
18
14
|
if (process.platform === 'win32') {
|
|
19
15
|
// Windows does not expose POSIX ownership changes; keep existence checks consistent.
|
|
20
16
|
node_fs_1.default.lstatSync(src);
|
|
21
|
-
return
|
|
17
|
+
return;
|
|
22
18
|
}
|
|
23
19
|
(0, recurse_io_sync_1.chownSync)(src, uid, gid);
|
|
24
|
-
return
|
|
20
|
+
return;
|
|
25
21
|
}
|
|
26
22
|
if (process.platform === 'win32') {
|
|
27
23
|
return new Promise((resolve, reject) => {
|
|
24
|
+
try {
|
|
25
|
+
src = this.resolve(src);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
reject(err);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
28
31
|
// Match Unix behavior by validating the path even when ownership cannot be changed.
|
|
29
32
|
node_fs_1.default.lstat(src, (err) => {
|
|
30
33
|
if (err) {
|
|
@@ -35,6 +38,13 @@ function chown(src, options) {
|
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
40
|
return new Promise((resolve, reject) => {
|
|
41
|
+
try {
|
|
42
|
+
src = this.resolve(src);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
reject(err);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
38
48
|
(0, recurse_io_1.chown)(src, uid, gid, (err) => {
|
|
39
49
|
if (err) {
|
|
40
50
|
return reject(err);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { CopyFilter, PoweredFileSystem } from '../powered-file-system';
|
|
2
|
-
|
|
3
|
-
* Resolves source and destination paths before delegating recursive copy work.
|
|
4
|
-
*/
|
|
5
|
-
export declare function copy<T extends boolean = false>(this: PoweredFileSystem, src: string, dest: string, options?: {
|
|
6
|
-
sync?: T;
|
|
1
|
+
import type { AsyncOption, CopyFilter, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
|
+
type CopyOptions = {
|
|
7
3
|
umask?: number;
|
|
8
4
|
overwrite?: boolean;
|
|
9
5
|
filter?: CopyFilter;
|
|
10
|
-
}
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Resolves source and destination paths before delegating recursive copy work.
|
|
9
|
+
*/
|
|
10
|
+
export declare function copy(this: PoweredFileSystem, src: string, dest: string, options: SyncOption & CopyOptions): void;
|
|
11
|
+
export declare function copy(this: PoweredFileSystem, src: string, dest: string, options?: AsyncOption & CopyOptions): Promise<void>;
|
|
12
|
+
export declare function copy(this: PoweredFileSystem, src: string, dest: string, options?: MaybeSyncOption & CopyOptions): void | Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.copy = copy;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
4
|
const recurse_io_1 = require("../recurse-io");
|
|
9
5
|
const recurse_io_sync_1 = require("../recurse-io-sync");
|
|
10
|
-
/**
|
|
11
|
-
* Resolves source and destination paths before delegating recursive copy work.
|
|
12
|
-
*/
|
|
13
6
|
function copy(src, dest, options) {
|
|
14
|
-
src = node_path_1.default.resolve(this.pwd, src);
|
|
15
|
-
dest = node_path_1.default.resolve(this.pwd, dest);
|
|
16
7
|
const { sync = false, umask = 0o000, overwrite = false, filter } = options ?? {};
|
|
17
|
-
const copyOptions = { umask, overwrite, filter };
|
|
8
|
+
const copyOptions = filter ? { umask, overwrite, filter } : { umask, overwrite };
|
|
18
9
|
if (sync) {
|
|
19
|
-
(0, recurse_io_sync_1.copySync)(src, dest, copyOptions);
|
|
20
|
-
return
|
|
10
|
+
(0, recurse_io_sync_1.copySync)(this.resolve(src), this.resolve(dest), copyOptions);
|
|
11
|
+
return;
|
|
21
12
|
}
|
|
22
13
|
return new Promise((resolve, reject) => {
|
|
14
|
+
try {
|
|
15
|
+
src = this.resolve(src);
|
|
16
|
+
dest = this.resolve(dest);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
reject(err);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
23
22
|
(0, recurse_io_1.copy)(src, dest, copyOptions, (err) => {
|
|
24
23
|
if (err) {
|
|
25
24
|
return reject(err);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
2
|
/**
|
|
3
3
|
* Removes directory contents while preserving the directory itself.
|
|
4
4
|
*/
|
|
5
|
-
export declare function emptyDir
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export declare function emptyDir(this: PoweredFileSystem, src: string, options: SyncOption): void;
|
|
6
|
+
export declare function emptyDir(this: PoweredFileSystem, src: string, options?: AsyncOption): Promise<void>;
|
|
7
|
+
export declare function emptyDir(this: PoweredFileSystem, src: string, options?: MaybeSyncOption): void | Promise<void>;
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.emptyDir = emptyDir;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
4
|
const recurse_io_1 = require("../recurse-io");
|
|
9
5
|
const recurse_io_sync_1 = require("../recurse-io-sync");
|
|
10
|
-
/**
|
|
11
|
-
* Removes directory contents while preserving the directory itself.
|
|
12
|
-
*/
|
|
13
6
|
function emptyDir(src, options) {
|
|
14
|
-
src = node_path_1.default.resolve(this.pwd, src);
|
|
15
7
|
const { sync = false } = options ?? {};
|
|
16
8
|
if (sync) {
|
|
17
|
-
(0, recurse_io_sync_1.emptyDirSync)(src);
|
|
18
|
-
return
|
|
9
|
+
(0, recurse_io_sync_1.emptyDirSync)(this.resolve(src));
|
|
10
|
+
return;
|
|
19
11
|
}
|
|
20
12
|
return new Promise((resolve, reject) => {
|
|
13
|
+
try {
|
|
14
|
+
src = this.resolve(src);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
reject(err);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
21
20
|
(0, recurse_io_1.emptyDir)(src, (err) => {
|
|
22
21
|
if (err) {
|
|
23
22
|
return reject(err);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
|
+
type MkdirOptions = {
|
|
3
|
+
umask?: number;
|
|
4
|
+
};
|
|
2
5
|
/**
|
|
3
|
-
* Creates directories relative to the instance
|
|
6
|
+
* Creates directories relative to the instance base path.
|
|
4
7
|
*/
|
|
5
|
-
export declare function mkdir
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
8
|
+
export declare function mkdir(this: PoweredFileSystem, dir: string, options: SyncOption & MkdirOptions): void;
|
|
9
|
+
export declare function mkdir(this: PoweredFileSystem, dir: string, options?: AsyncOption & MkdirOptions): Promise<void>;
|
|
10
|
+
export declare function mkdir(this: PoweredFileSystem, dir: string, options?: MaybeSyncOption & MkdirOptions): void | Promise<void>;
|
|
11
|
+
export {};
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.mkdir = mkdir;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
4
|
const recurse_io_1 = require("../recurse-io");
|
|
9
5
|
const recurse_io_sync_1 = require("../recurse-io-sync");
|
|
10
|
-
/**
|
|
11
|
-
* Creates directories relative to the instance root.
|
|
12
|
-
*/
|
|
13
6
|
function mkdir(dir, options) {
|
|
14
7
|
const { sync = false, umask = 0o000 } = options ?? {};
|
|
15
|
-
dir = node_path_1.default.resolve(this.pwd, dir);
|
|
16
8
|
if (sync) {
|
|
17
|
-
(0, recurse_io_sync_1.mkdirSync)(dir, umask);
|
|
18
|
-
return
|
|
9
|
+
(0, recurse_io_sync_1.mkdirSync)(this.resolve(dir), umask);
|
|
10
|
+
return;
|
|
19
11
|
}
|
|
20
12
|
return new Promise((resolve, reject) => {
|
|
13
|
+
try {
|
|
14
|
+
dir = this.resolve(dir);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
reject(err);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
21
20
|
(0, recurse_io_1.mkdir)(dir, umask, (err) => {
|
|
22
21
|
if (err) {
|
|
23
22
|
return reject(err);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, ReadOptions, SyncOption } from '../powered-file-system';
|
|
2
2
|
/**
|
|
3
3
|
* Reads a file relative to `pwd` and preserves Buffer mode when `encoding` is `null`.
|
|
4
4
|
*/
|
|
5
|
-
export declare function read
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export declare function read(this: PoweredFileSystem, src: string, options: SyncOption & ReadOptions<true, null> & {
|
|
6
|
+
encoding: null;
|
|
7
|
+
}): Buffer;
|
|
8
|
+
export declare function read(this: PoweredFileSystem, src: string, options: SyncOption & ReadOptions<true, BufferEncoding>): string;
|
|
9
|
+
export declare function read(this: PoweredFileSystem, src: string, options: AsyncOption & ReadOptions<false, null> & {
|
|
10
|
+
encoding: null;
|
|
11
|
+
}): Promise<Buffer>;
|
|
12
|
+
export declare function read(this: PoweredFileSystem, src: string, options?: AsyncOption & ReadOptions<false, BufferEncoding>): Promise<string>;
|
|
13
|
+
export declare function read(this: PoweredFileSystem, src: string, options?: MaybeSyncOption & ReadOptions<boolean, BufferEncoding | null>): string | Buffer | Promise<string | Buffer>;
|
|
@@ -5,20 +5,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.read = read;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
/**
|
|
10
|
-
* Reads a file relative to `pwd` and preserves Buffer mode when `encoding` is `null`.
|
|
11
|
-
*/
|
|
12
8
|
function read(src, options) {
|
|
13
9
|
const { sync = false, encoding = 'utf8', flag = 'r' } = options ?? {};
|
|
14
|
-
const resolved = node_path_1.default.resolve(this.pwd, src);
|
|
15
10
|
if (sync) {
|
|
11
|
+
const resolved = this.resolve(src);
|
|
16
12
|
if (encoding === null) {
|
|
17
13
|
return node_fs_1.default.readFileSync(resolved, { encoding: null, flag });
|
|
18
14
|
}
|
|
19
15
|
return node_fs_1.default.readFileSync(resolved, { encoding, flag });
|
|
20
16
|
}
|
|
21
17
|
return new Promise((resolve, reject) => {
|
|
18
|
+
let resolved;
|
|
19
|
+
try {
|
|
20
|
+
resolved = this.resolve(src);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
reject(err);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
22
26
|
node_fs_1.default.readFile(resolved, { encoding, flag }, (err, raw) => {
|
|
23
27
|
if (err) {
|
|
24
28
|
return reject(err);
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, ReaddirOptions, SyncOption } from '../powered-file-system';
|
|
2
2
|
/**
|
|
3
|
-
* Lists directory entries relative to the
|
|
3
|
+
* Lists directory entries relative to the instance base path.
|
|
4
4
|
*/
|
|
5
|
-
export declare function readdir
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export declare function readdir(this: PoweredFileSystem, dir: string, options: SyncOption & ReaddirOptions<true, null> & {
|
|
6
|
+
encoding: null;
|
|
7
|
+
}): Buffer[];
|
|
8
|
+
export declare function readdir(this: PoweredFileSystem, dir: string, options: SyncOption & ReaddirOptions<true, BufferEncoding>): string[];
|
|
9
|
+
export declare function readdir(this: PoweredFileSystem, dir: string, options: AsyncOption & ReaddirOptions<false, null> & {
|
|
10
|
+
encoding: null;
|
|
11
|
+
}): Promise<Buffer[]>;
|
|
12
|
+
export declare function readdir(this: PoweredFileSystem, dir: string, options?: AsyncOption & ReaddirOptions<false, BufferEncoding>): Promise<string[]>;
|
|
13
|
+
export declare function readdir(this: PoweredFileSystem, dir: string, options?: MaybeSyncOption & ReaddirOptions<boolean, BufferEncoding | null>): string[] | Buffer[] | Promise<string[] | Buffer[]>;
|
|
@@ -5,17 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.readdir = readdir;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
/**
|
|
10
|
-
* Lists directory entries relative to the current instance root.
|
|
11
|
-
*/
|
|
12
8
|
function readdir(dir, options) {
|
|
13
9
|
const { sync = false, encoding = 'utf8' } = options ?? {};
|
|
14
|
-
dir = node_path_1.default.resolve(this.pwd, dir);
|
|
15
10
|
if (sync) {
|
|
16
|
-
return node_fs_1.default.readdirSync(dir, { encoding });
|
|
11
|
+
return node_fs_1.default.readdirSync(this.resolve(dir), { encoding });
|
|
17
12
|
}
|
|
18
13
|
return new Promise((resolve, reject) => {
|
|
14
|
+
try {
|
|
15
|
+
dir = this.resolve(dir);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
reject(err);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
19
21
|
node_fs_1.default.readdir(dir, { encoding }, (err, list) => {
|
|
20
22
|
if (err) {
|
|
21
23
|
return reject(err);
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
2
|
/**
|
|
3
3
|
* Reads the target path stored in a symbolic link.
|
|
4
4
|
*/
|
|
5
|
-
export declare function readlink
|
|
6
|
-
sync?: T;
|
|
5
|
+
export declare function readlink(this: PoweredFileSystem, src: string, options: SyncOption & {
|
|
7
6
|
encoding?: BufferEncoding;
|
|
8
|
-
}):
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function readlink(this: PoweredFileSystem, src: string, options?: AsyncOption & {
|
|
9
|
+
encoding?: BufferEncoding;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
export declare function readlink(this: PoweredFileSystem, src: string, options?: MaybeSyncOption & {
|
|
12
|
+
encoding?: BufferEncoding;
|
|
13
|
+
}): string | Promise<string>;
|
|
@@ -5,17 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.readlink = readlink;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
/**
|
|
10
|
-
* Reads the target path stored in a symbolic link.
|
|
11
|
-
*/
|
|
12
8
|
function readlink(src, options) {
|
|
13
|
-
src = node_path_1.default.resolve(this.pwd, src);
|
|
14
9
|
const { sync = false, encoding = 'utf8' } = options ?? {};
|
|
15
10
|
if (sync) {
|
|
16
|
-
return node_fs_1.default.readlinkSync(src, { encoding });
|
|
11
|
+
return node_fs_1.default.readlinkSync(this.resolve(src), { encoding });
|
|
17
12
|
}
|
|
18
13
|
return new Promise((resolve, reject) => {
|
|
14
|
+
try {
|
|
15
|
+
src = this.resolve(src);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
reject(err);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
19
21
|
node_fs_1.default.readlink(src, { encoding }, (err, resolved) => {
|
|
20
22
|
if (err) {
|
|
21
23
|
return reject(err);
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
2
|
/**
|
|
3
3
|
* Resolves a path to its canonical absolute location.
|
|
4
4
|
*/
|
|
5
|
-
export declare function realpath
|
|
6
|
-
sync?: T;
|
|
5
|
+
export declare function realpath(this: PoweredFileSystem, src: string, options: SyncOption & {
|
|
7
6
|
encoding?: BufferEncoding;
|
|
8
|
-
}):
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function realpath(this: PoweredFileSystem, src: string, options?: AsyncOption & {
|
|
9
|
+
encoding?: BufferEncoding;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
export declare function realpath(this: PoweredFileSystem, src: string, options?: MaybeSyncOption & {
|
|
12
|
+
encoding?: BufferEncoding;
|
|
13
|
+
}): string | Promise<string>;
|
|
@@ -5,17 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.realpath = realpath;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
/**
|
|
10
|
-
* Resolves a path to its canonical absolute location.
|
|
11
|
-
*/
|
|
12
8
|
function realpath(src, options) {
|
|
13
|
-
src = node_path_1.default.resolve(this.pwd, src);
|
|
14
9
|
const { sync = false, encoding = 'utf8' } = options ?? {};
|
|
15
10
|
if (sync) {
|
|
16
|
-
return node_fs_1.default.realpathSync(src, { encoding });
|
|
11
|
+
return node_fs_1.default.realpathSync(this.resolve(src), { encoding });
|
|
17
12
|
}
|
|
18
13
|
return new Promise((resolve, reject) => {
|
|
14
|
+
try {
|
|
15
|
+
src = this.resolve(src);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
reject(err);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
19
21
|
node_fs_1.default.realpath(src, { encoding }, (err, resolved) => {
|
|
20
22
|
if (err) {
|
|
21
23
|
return reject(err);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
2
|
/**
|
|
3
|
-
* Removes a path relative to the instance
|
|
3
|
+
* Removes a path relative to the instance base path.
|
|
4
4
|
*/
|
|
5
|
-
export declare function remove
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export declare function remove(this: PoweredFileSystem, src: string, options: SyncOption): void;
|
|
6
|
+
export declare function remove(this: PoweredFileSystem, src: string, options?: AsyncOption): Promise<void>;
|
|
7
|
+
export declare function remove(this: PoweredFileSystem, src: string, options?: MaybeSyncOption): void | Promise<void>;
|
|
@@ -1,36 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.remove = remove;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
4
|
const recurse_io_1 = require("../recurse-io");
|
|
10
5
|
const recurse_io_sync_1 = require("../recurse-io-sync");
|
|
11
|
-
/**
|
|
12
|
-
* Removes a path relative to the instance root, preferring native recursive APIs when available.
|
|
13
|
-
*/
|
|
14
6
|
function remove(src, options) {
|
|
15
|
-
src = node_path_1.default.resolve(this.pwd, src);
|
|
16
7
|
const { sync = false } = options ?? {};
|
|
17
8
|
if (sync) {
|
|
18
|
-
(0, recurse_io_sync_1.removeSync)(src);
|
|
19
|
-
return
|
|
9
|
+
(0, recurse_io_sync_1.removeSync)(this.resolve(src));
|
|
10
|
+
return;
|
|
20
11
|
}
|
|
21
12
|
return new Promise((resolve, reject) => {
|
|
22
|
-
|
|
13
|
+
try {
|
|
14
|
+
src = this.resolve(src);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
reject(err);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
(0, recurse_io_1.remove)(src, (err) => {
|
|
23
21
|
if (err) {
|
|
24
22
|
return reject(err);
|
|
25
23
|
}
|
|
26
24
|
resolve();
|
|
27
|
-
};
|
|
28
|
-
if ('rm' in node_fs_1.default) {
|
|
29
|
-
// Prefer the native recursive removal when the runtime supports it.
|
|
30
|
-
node_fs_1.default.rm(src, { recursive: true }, callback);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
(0, recurse_io_1.remove)(src, callback);
|
|
34
|
-
}
|
|
25
|
+
});
|
|
35
26
|
});
|
|
36
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PoweredFileSystem } from '../powered-file-system';
|
|
1
|
+
import type { AsyncOption, MaybeSyncOption, PoweredFileSystem, SyncOption } from '../powered-file-system';
|
|
2
2
|
/**
|
|
3
|
-
* Resolves both paths against the instance
|
|
3
|
+
* Resolves both paths against the instance base path before delegating to Node's rename API.
|
|
4
4
|
*/
|
|
5
|
-
export declare function rename
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export declare function rename(this: PoweredFileSystem, src: string, dest: string, options: SyncOption): void;
|
|
6
|
+
export declare function rename(this: PoweredFileSystem, src: string, dest: string, options?: AsyncOption): Promise<void>;
|
|
7
|
+
export declare function rename(this: PoweredFileSystem, src: string, dest: string, options?: MaybeSyncOption): void | Promise<void>;
|
|
@@ -5,19 +5,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.rename = rename;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
/**
|
|
10
|
-
* Resolves both paths against the instance root before delegating to Node's rename API.
|
|
11
|
-
*/
|
|
12
8
|
function rename(src, dest, options) {
|
|
13
|
-
src = node_path_1.default.resolve(this.pwd, src);
|
|
14
|
-
dest = node_path_1.default.resolve(this.pwd, dest);
|
|
15
9
|
const { sync = false } = options ?? {};
|
|
16
10
|
if (sync) {
|
|
11
|
+
src = this.resolve(src);
|
|
12
|
+
dest = this.resolve(dest);
|
|
17
13
|
node_fs_1.default.renameSync(src, dest);
|
|
18
|
-
return
|
|
14
|
+
return;
|
|
19
15
|
}
|
|
20
16
|
return new Promise((resolve, reject) => {
|
|
17
|
+
try {
|
|
18
|
+
src = this.resolve(src);
|
|
19
|
+
dest = this.resolve(dest);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
reject(err);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
21
25
|
node_fs_1.default.rename(src, dest, (err) => {
|
|
22
26
|
if (err) {
|
|
23
27
|
return reject(err);
|