@reliverse/relifso 1.2.5 → 1.2.7
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/bin/impl/mkdirs.d.ts +2 -1
- package/bin/impl/output-json.d.ts +2 -2
- package/bin/impl/write-json.d.ts +2 -2
- package/bin/impl/write-json.js +4 -4
- package/bin/mod.d.ts +155 -41
- package/bin/mod.js +369 -74
- package/package.json +2 -2
package/bin/impl/mkdirs.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
interface MakeDirectoryOptions {
|
|
2
2
|
recursive?: boolean;
|
|
3
3
|
mode?: number | string;
|
|
4
4
|
}
|
|
5
5
|
export declare function mkdirsSync(dir: string, options?: MakeDirectoryOptions): string | undefined;
|
|
6
6
|
export declare function mkdirs(dir: string, options?: MakeDirectoryOptions): Promise<string | undefined>;
|
|
7
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param file - The path to the file.
|
|
5
5
|
* @param data - The JSON data to write.
|
|
6
|
-
* @param options - Options for writing the JSON file (e.g., replacer,
|
|
6
|
+
* @param options - Options for writing the JSON file (e.g., replacer, spaces).
|
|
7
7
|
*/
|
|
8
8
|
export declare function outputJsonSync(file: string, data: unknown, options?: unknown): void;
|
|
9
9
|
/**
|
|
@@ -11,6 +11,6 @@ export declare function outputJsonSync(file: string, data: unknown, options?: un
|
|
|
11
11
|
*
|
|
12
12
|
* @param file - The path to the file.
|
|
13
13
|
* @param data - The JSON data to write.
|
|
14
|
-
* @param options - Options for writing the JSON file (e.g., replacer,
|
|
14
|
+
* @param options - Options for writing the JSON file (e.g., replacer, spaces).
|
|
15
15
|
*/
|
|
16
16
|
export declare function outputJson(file: string, data: unknown, options?: unknown): Promise<void>;
|
package/bin/impl/write-json.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Mode, OpenMode } from "node:fs";
|
|
2
2
|
export interface JsonStringifyOptions {
|
|
3
3
|
replacer?: (key: string, value: unknown) => unknown | (number | string)[] | null;
|
|
4
|
-
|
|
4
|
+
spaces?: string | number;
|
|
5
5
|
}
|
|
6
6
|
export interface WriteJsonOptions {
|
|
7
7
|
encoding?: BufferEncoding | null;
|
|
8
8
|
mode?: Mode;
|
|
9
9
|
flag?: OpenMode;
|
|
10
10
|
replacer?: (key: string, value: unknown) => unknown | (number | string)[] | null;
|
|
11
|
-
|
|
11
|
+
spaces?: string | number;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Synchronously writes an object to a JSON file.
|
package/bin/impl/write-json.js
CHANGED
|
@@ -2,21 +2,21 @@ import { writeFileSync } from "./write-file.js";
|
|
|
2
2
|
import { writeFile } from "./write-file.js";
|
|
3
3
|
export function writeJsonSync(file, object, options = {}) {
|
|
4
4
|
const replacer = options.replacer === void 0 ? null : options.replacer;
|
|
5
|
-
const
|
|
5
|
+
const spaces = options.spaces === void 0 ? 2 : options.spaces;
|
|
6
6
|
const fileWriteOpts = {};
|
|
7
7
|
if (options.encoding !== void 0) fileWriteOpts.encoding = options.encoding;
|
|
8
8
|
if (options.mode !== void 0) fileWriteOpts.mode = options.mode;
|
|
9
9
|
if (options.flag !== void 0) fileWriteOpts.flag = options.flag.toString();
|
|
10
|
-
const str = JSON.stringify(object, replacer,
|
|
10
|
+
const str = JSON.stringify(object, replacer, spaces);
|
|
11
11
|
writeFileSync(file, str, fileWriteOpts);
|
|
12
12
|
}
|
|
13
13
|
export async function writeJson(file, object, options = {}) {
|
|
14
14
|
const replacer = options.replacer === void 0 ? null : options.replacer;
|
|
15
|
-
const
|
|
15
|
+
const spaces = options.spaces === void 0 ? 2 : options.spaces;
|
|
16
16
|
const fileWriteOpts = {};
|
|
17
17
|
if (options.encoding !== void 0) fileWriteOpts.encoding = options.encoding;
|
|
18
18
|
if (options.mode !== void 0) fileWriteOpts.mode = options.mode;
|
|
19
19
|
if (options.flag !== void 0) fileWriteOpts.flag = options.flag.toString();
|
|
20
|
-
const str = JSON.stringify(object, replacer,
|
|
20
|
+
const str = JSON.stringify(object, replacer, spaces);
|
|
21
21
|
await writeFile(file, str, fileWriteOpts);
|
|
22
22
|
}
|
package/bin/mod.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Stats } from "node:fs";
|
|
2
|
-
import { accessSync, constants, readdirSync, statSync, copyFileSync } from "node:fs";
|
|
3
|
-
import { readdir as nodeReaddirInternal, stat as nodeStatInternal,
|
|
2
|
+
import { renameSync as nodeRenameSync, unlinkSync as nodeUnlinkSync, accessSync, constants, readdirSync, statSync, copyFileSync, appendFileSync, chmodSync, chownSync, closeSync, createReadStream, createWriteStream, fchmodSync, fchownSync, fdatasyncSync, fstatSync, fsyncSync, ftruncateSync, futimesSync, lchmodSync, lchownSync, linkSync, lstatSync, lutimesSync, mkdtempSync, openSync, opendirSync, readSync, readlinkSync, realpathSync, rmSync, rmdirSync, statfsSync, symlinkSync, truncateSync, unwatchFile, utimesSync, watchFile, writeFileSync, writeSync, readvSync, writevSync } from "node:fs";
|
|
3
|
+
import { readdir as nodeReaddirInternal, stat as nodeStatInternal, rename as nodeRename, unlink as nodeUnlink, access, appendFile, chmod, chown, copyFile, lchmod, lchown, link, lstat, lutimes, mkdtemp, open, opendir, readdir, readlink, realpath, rm, rmdir, stat, statfs, symlink, truncate, utimes, watch, writeFile } from "node:fs/promises";
|
|
4
|
+
import { resolve } from "node:path";
|
|
4
5
|
import type { DiveOptions } from "./impl/dive.js";
|
|
5
6
|
import { copy, copySync } from "./impl/copy.js";
|
|
6
7
|
import { createFile, createFileSync } from "./impl/create-file.js";
|
|
@@ -14,8 +15,14 @@ import { pathExists, pathExistsSync } from "./impl/path-exists.js";
|
|
|
14
15
|
import { readFile, readFileSync } from "./impl/read-file.js";
|
|
15
16
|
import { readJson, readJsonSync } from "./impl/read-json.js";
|
|
16
17
|
import { remove, removeSync } from "./impl/remove.js";
|
|
17
|
-
import { writeFile, writeFileSync } from "./impl/write-file.js";
|
|
18
18
|
import { writeJson, writeJsonSync } from "./impl/write-json.js";
|
|
19
|
+
/**
|
|
20
|
+
* Recursively dives into a directory and yields files and directories.
|
|
21
|
+
* @param directory - The directory to dive into.
|
|
22
|
+
* @param action - An optional callback function to execute for each file or directory.
|
|
23
|
+
* @param options - An optional object containing options for the dive.
|
|
24
|
+
* @returns A Promise that resolves to an array of file paths if no action is provided, or void if an action is provided.
|
|
25
|
+
*/
|
|
19
26
|
export declare function dive(directory: string, action: (file: string, stat: Stats) => void | Promise<void>, options?: DiveOptions): Promise<void>;
|
|
20
27
|
export declare function dive(directory: string, options?: DiveOptions): Promise<string[]>;
|
|
21
28
|
declare const mkdirp: typeof mkdirs;
|
|
@@ -34,66 +41,173 @@ declare const unlink: typeof remove;
|
|
|
34
41
|
declare const unlinkSync: typeof removeSync;
|
|
35
42
|
declare const rename: typeof move;
|
|
36
43
|
declare const renameSync: typeof moveSync;
|
|
44
|
+
declare const readJSON: typeof readJson;
|
|
45
|
+
declare const readJSONSync: typeof readJsonSync;
|
|
46
|
+
declare const writeJSON: typeof writeJson;
|
|
47
|
+
declare const writeJSONSync: typeof writeJsonSync;
|
|
48
|
+
declare const outputJSON: typeof outputJson;
|
|
49
|
+
declare const outputJSONSync: typeof outputJsonSync;
|
|
50
|
+
declare const cp: typeof copy;
|
|
51
|
+
declare const cpSync: typeof copySync;
|
|
52
|
+
declare const exists: typeof pathExists;
|
|
53
|
+
declare const existsSync: typeof pathExistsSync;
|
|
54
|
+
declare function readText(filePath: string, options?: BufferEncoding | {
|
|
55
|
+
encoding?: BufferEncoding | null;
|
|
56
|
+
flag?: string;
|
|
57
|
+
}): Promise<string>;
|
|
58
|
+
declare function readTextSync(filePath: string, options?: BufferEncoding | {
|
|
59
|
+
encoding?: BufferEncoding | null;
|
|
60
|
+
flag?: string;
|
|
61
|
+
}): string;
|
|
62
|
+
declare function readLines(filePath: string, options?: BufferEncoding | {
|
|
63
|
+
encoding?: BufferEncoding | null;
|
|
64
|
+
flag?: string;
|
|
65
|
+
}): Promise<any>;
|
|
66
|
+
declare function readLinesSync(filePath: string, options?: BufferEncoding | {
|
|
67
|
+
encoding?: BufferEncoding | null;
|
|
68
|
+
flag?: string;
|
|
69
|
+
}): any;
|
|
70
|
+
declare function isDirectory(filePath: string): Promise<boolean>;
|
|
71
|
+
declare function isDirectorySync(filePath: string): boolean;
|
|
72
|
+
declare function isSymlink(filePath: string): Promise<boolean>;
|
|
73
|
+
declare function isSymlinkSync(filePath: string): boolean;
|
|
37
74
|
export type { CopyOptions } from "./impl/copy.js";
|
|
38
75
|
export type { MoveOptions } from "./impl/move.js";
|
|
39
76
|
export type { ReadFileOptions } from "./impl/read-file.js";
|
|
40
77
|
export type { ReadJsonOptions } from "./impl/read-json.js";
|
|
41
78
|
export type { JsonStringifyOptions } from "./impl/write-json.js";
|
|
42
79
|
export type { WriteJsonOptions } from "./impl/write-json.js";
|
|
43
|
-
export {
|
|
80
|
+
export { accessSync, appendFileSync, chmodSync, chownSync, closeSync, copyFileSync, createReadStream, createWriteStream, fchmodSync, fchownSync, fdatasyncSync, fstatSync, fsyncSync, ftruncateSync, futimesSync, lchmodSync, lchownSync, linkSync, lstatSync, lutimesSync, mkdtempSync, openSync, opendirSync, readFileSync, readlinkSync, readSync, readdirSync, realpathSync, nodeRenameSync, rmSync, rmdirSync, statSync, statfsSync, symlinkSync, truncateSync, nodeUnlinkSync, unwatchFile, utimesSync, watchFile, writeFileSync, writeSync, readvSync, writevSync, readJsonSync, writeJsonSync, createFileSync, mkdirsSync, emptyDirSync, pathExistsSync, copySync, moveSync, removeSync, outputJsonSync, outputFileSync, diveSync, cpSync, ensureDirSync, ensureFileSync, existsSync, mkdirpSync, mkdirSync, ncpSync, outputJSONSync, readJSONSync, renameSync, rimrafSync, unlinkSync, writeJSONSync, isDirectorySync, isSymlinkSync, readLinesSync, readTextSync, readJson, writeJson, createFile, mkdirs, emptyDir, pathExists, copy, move, remove, outputJson, outputFile, access, appendFile, chmod, chown, copyFile, lchmod, lchown, link, lstat, lutimes, mkdtemp, open, opendir, readFile, readdir, readlink, realpath, nodeRename, rm, rmdir, stat, statfs, symlink, truncate, nodeUnlink, utimes, watch, writeFile, constants, cp, ensureDir, ensureFile, exists, mkdir, mkdirp, ncp, outputJSON, readJSON, rename, resolve, rimraf, unlink, writeJSON, isDirectory, isSymlink, readLines, readText, };
|
|
44
81
|
declare const fs: {
|
|
82
|
+
accessSync: typeof accessSync;
|
|
83
|
+
appendFileSync: typeof appendFileSync;
|
|
84
|
+
chmodSync: typeof chmodSync;
|
|
85
|
+
chownSync: typeof chownSync;
|
|
86
|
+
closeSync: typeof closeSync;
|
|
87
|
+
copyFileSync: typeof copyFileSync;
|
|
88
|
+
createReadStream: typeof createReadStream;
|
|
89
|
+
createWriteStream: typeof createWriteStream;
|
|
90
|
+
fchmodSync: typeof fchmodSync;
|
|
91
|
+
fchownSync: typeof fchownSync;
|
|
92
|
+
fdatasyncSync: typeof fdatasyncSync;
|
|
93
|
+
fstatSync: typeof fstatSync;
|
|
94
|
+
fsyncSync: typeof fsyncSync;
|
|
95
|
+
ftruncateSync: typeof ftruncateSync;
|
|
96
|
+
futimesSync: typeof futimesSync;
|
|
97
|
+
lchmodSync: typeof lchmodSync;
|
|
98
|
+
lchownSync: typeof lchownSync;
|
|
99
|
+
linkSync: typeof linkSync;
|
|
100
|
+
lstatSync: import("fs").StatSyncFn;
|
|
101
|
+
lutimesSync: typeof lutimesSync;
|
|
102
|
+
mkdtempSync: typeof mkdtempSync;
|
|
103
|
+
openSync: typeof openSync;
|
|
104
|
+
opendirSync: typeof opendirSync;
|
|
105
|
+
readFileSync: typeof readFileSync;
|
|
106
|
+
readlinkSync: typeof readlinkSync;
|
|
107
|
+
readSync: typeof readSync;
|
|
108
|
+
readdirSync: typeof readdirSync;
|
|
109
|
+
realpathSync: typeof realpathSync;
|
|
110
|
+
nodeRenameSync: typeof nodeRenameSync;
|
|
111
|
+
rmSync: typeof rmSync;
|
|
112
|
+
rmdirSync: typeof rmdirSync;
|
|
113
|
+
statSync: import("fs").StatSyncFn;
|
|
114
|
+
statfsSync: typeof statfsSync;
|
|
115
|
+
symlinkSync: typeof symlinkSync;
|
|
116
|
+
truncateSync: typeof truncateSync;
|
|
117
|
+
nodeUnlinkSync: typeof nodeUnlinkSync;
|
|
118
|
+
unwatchFile: typeof unwatchFile;
|
|
119
|
+
utimesSync: typeof utimesSync;
|
|
120
|
+
watchFile: typeof watchFile;
|
|
121
|
+
writeFileSync: typeof writeFileSync;
|
|
122
|
+
writeSync: typeof writeSync;
|
|
123
|
+
readvSync: typeof readvSync;
|
|
124
|
+
writevSync: typeof writevSync;
|
|
125
|
+
readJsonSync: typeof readJsonSync;
|
|
126
|
+
writeJsonSync: typeof writeJsonSync;
|
|
127
|
+
createFileSync: typeof createFileSync;
|
|
128
|
+
mkdirsSync: typeof mkdirsSync;
|
|
129
|
+
emptyDirSync: typeof emptyDirSync;
|
|
130
|
+
pathExistsSync: typeof pathExistsSync;
|
|
131
|
+
copySync: typeof copySync;
|
|
132
|
+
moveSync: typeof moveSync;
|
|
133
|
+
removeSync: typeof removeSync;
|
|
134
|
+
outputJsonSync: typeof outputJsonSync;
|
|
135
|
+
outputFileSync: typeof outputFileSync;
|
|
136
|
+
diveSync: typeof diveSync;
|
|
137
|
+
cpSync: typeof copySync;
|
|
138
|
+
ensureDirSync: typeof mkdirsSync;
|
|
139
|
+
ensureFileSync: typeof createFileSync;
|
|
140
|
+
existsSync: typeof pathExistsSync;
|
|
141
|
+
mkdirpSync: typeof mkdirsSync;
|
|
142
|
+
mkdirSync: typeof mkdirsSync;
|
|
143
|
+
ncpSync: typeof copySync;
|
|
144
|
+
outputJSONSync: typeof outputJsonSync;
|
|
145
|
+
readJSONSync: typeof readJsonSync;
|
|
146
|
+
renameSync: typeof moveSync;
|
|
147
|
+
rimrafSync: typeof removeSync;
|
|
148
|
+
unlinkSync: typeof removeSync;
|
|
149
|
+
writeJSONSync: typeof writeJsonSync;
|
|
150
|
+
isDirectorySync: typeof isDirectorySync;
|
|
151
|
+
isSymlinkSync: typeof isSymlinkSync;
|
|
152
|
+
readLinesSync: typeof readLinesSync;
|
|
153
|
+
readTextSync: typeof readTextSync;
|
|
45
154
|
readJson: typeof readJson;
|
|
46
155
|
writeJson: typeof writeJson;
|
|
47
156
|
createFile: typeof createFile;
|
|
48
|
-
writeFile: typeof writeFile;
|
|
49
|
-
readFile: typeof readFile;
|
|
50
157
|
mkdirs: typeof mkdirs;
|
|
51
158
|
emptyDir: typeof emptyDir;
|
|
52
159
|
pathExists: typeof pathExists;
|
|
53
160
|
copy: typeof copy;
|
|
54
161
|
move: typeof move;
|
|
55
162
|
remove: typeof remove;
|
|
56
|
-
|
|
57
|
-
|
|
163
|
+
outputJson: typeof outputJson;
|
|
164
|
+
outputFile: typeof outputFile;
|
|
58
165
|
access: typeof access;
|
|
166
|
+
appendFile: typeof appendFile;
|
|
167
|
+
chmod: typeof chmod;
|
|
168
|
+
chown: typeof chown;
|
|
59
169
|
copyFile: typeof copyFile;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
170
|
+
lchmod: typeof lchmod;
|
|
171
|
+
lchown: typeof lchown;
|
|
172
|
+
link: typeof link;
|
|
173
|
+
lstat: typeof lstat;
|
|
174
|
+
lutimes: typeof lutimes;
|
|
175
|
+
mkdtemp: typeof mkdtemp;
|
|
176
|
+
open: typeof open;
|
|
177
|
+
opendir: typeof opendir;
|
|
178
|
+
readFile: typeof readFile;
|
|
179
|
+
readdir: typeof nodeReaddirInternal;
|
|
180
|
+
readlink: typeof readlink;
|
|
181
|
+
realpath: typeof realpath;
|
|
182
|
+
nodeRename: typeof nodeRename;
|
|
183
|
+
rm: typeof rm;
|
|
184
|
+
rmdir: typeof rmdir;
|
|
185
|
+
stat: typeof nodeStatInternal;
|
|
186
|
+
statfs: typeof statfs;
|
|
187
|
+
symlink: typeof symlink;
|
|
188
|
+
truncate: typeof truncate;
|
|
189
|
+
nodeUnlink: typeof nodeUnlink;
|
|
190
|
+
utimes: typeof utimes;
|
|
191
|
+
watch: typeof watch;
|
|
192
|
+
writeFile: typeof writeFile;
|
|
74
193
|
constants: typeof constants;
|
|
75
|
-
|
|
76
|
-
mkdirp: typeof mkdirs;
|
|
77
|
-
mkdirpSync: typeof mkdirsSync;
|
|
78
|
-
rimraf: typeof remove;
|
|
79
|
-
rimrafSync: typeof removeSync;
|
|
80
|
-
ncp: typeof copy;
|
|
81
|
-
ncpSync: typeof copySync;
|
|
194
|
+
cp: typeof copy;
|
|
82
195
|
ensureDir: typeof mkdirs;
|
|
83
|
-
ensureDirSync: typeof mkdirsSync;
|
|
84
196
|
ensureFile: typeof createFile;
|
|
85
|
-
|
|
86
|
-
outputJson: typeof outputJson;
|
|
87
|
-
outputJsonSync: typeof outputJsonSync;
|
|
88
|
-
outputFile: typeof outputFile;
|
|
89
|
-
outputFileSync: typeof outputFileSync;
|
|
90
|
-
dive: typeof dive;
|
|
91
|
-
diveSync: typeof diveSync;
|
|
197
|
+
exists: typeof pathExists;
|
|
92
198
|
mkdir: typeof mkdirs;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
199
|
+
mkdirp: typeof mkdirs;
|
|
200
|
+
ncp: typeof copy;
|
|
201
|
+
outputJSON: typeof outputJson;
|
|
202
|
+
readJSON: typeof readJson;
|
|
96
203
|
rename: typeof move;
|
|
97
|
-
|
|
204
|
+
resolve: (...paths: string[]) => string;
|
|
205
|
+
rimraf: typeof remove;
|
|
206
|
+
unlink: typeof remove;
|
|
207
|
+
writeJSON: typeof writeJson;
|
|
208
|
+
isDirectory: typeof isDirectory;
|
|
209
|
+
isSymlink: typeof isSymlink;
|
|
210
|
+
readLines: typeof readLines;
|
|
211
|
+
readText: typeof readText;
|
|
98
212
|
};
|
|
99
213
|
export default fs;
|
package/bin/mod.js
CHANGED
|
@@ -1,13 +1,80 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
renameSync as nodeRenameSync,
|
|
3
|
+
unlinkSync as nodeUnlinkSync,
|
|
4
|
+
accessSync,
|
|
5
|
+
constants,
|
|
6
|
+
readdirSync,
|
|
7
|
+
statSync,
|
|
8
|
+
copyFileSync,
|
|
9
|
+
appendFileSync,
|
|
10
|
+
chmodSync,
|
|
11
|
+
chownSync,
|
|
12
|
+
closeSync,
|
|
13
|
+
createReadStream,
|
|
14
|
+
createWriteStream,
|
|
15
|
+
fchmodSync,
|
|
16
|
+
fchownSync,
|
|
17
|
+
fdatasyncSync,
|
|
18
|
+
fstatSync,
|
|
19
|
+
fsyncSync,
|
|
20
|
+
ftruncateSync,
|
|
21
|
+
futimesSync,
|
|
22
|
+
lchmodSync,
|
|
23
|
+
lchownSync,
|
|
24
|
+
linkSync,
|
|
25
|
+
lstatSync,
|
|
26
|
+
lutimesSync,
|
|
27
|
+
mkdtempSync,
|
|
28
|
+
openSync,
|
|
29
|
+
opendirSync,
|
|
30
|
+
readSync,
|
|
31
|
+
readlinkSync,
|
|
32
|
+
realpathSync,
|
|
33
|
+
rmSync,
|
|
34
|
+
rmdirSync,
|
|
35
|
+
statfsSync,
|
|
36
|
+
symlinkSync,
|
|
37
|
+
truncateSync,
|
|
38
|
+
unwatchFile,
|
|
39
|
+
utimesSync,
|
|
40
|
+
watchFile,
|
|
41
|
+
writeFileSync,
|
|
42
|
+
writeSync,
|
|
43
|
+
readvSync,
|
|
44
|
+
writevSync
|
|
45
|
+
} from "node:fs";
|
|
2
46
|
import {
|
|
3
47
|
readdir as nodeReaddirInternal,
|
|
4
48
|
stat as nodeStatInternal,
|
|
49
|
+
rename as nodeRename,
|
|
50
|
+
unlink as nodeUnlink,
|
|
51
|
+
access,
|
|
52
|
+
appendFile,
|
|
53
|
+
chmod,
|
|
54
|
+
chown,
|
|
55
|
+
copyFile,
|
|
56
|
+
lchmod,
|
|
57
|
+
lchown,
|
|
58
|
+
link,
|
|
59
|
+
lstat,
|
|
60
|
+
lutimes,
|
|
61
|
+
mkdtemp,
|
|
62
|
+
open,
|
|
63
|
+
opendir,
|
|
5
64
|
readdir,
|
|
65
|
+
readlink,
|
|
66
|
+
realpath,
|
|
67
|
+
rm,
|
|
68
|
+
rmdir,
|
|
6
69
|
stat,
|
|
7
|
-
|
|
8
|
-
|
|
70
|
+
statfs,
|
|
71
|
+
symlink,
|
|
72
|
+
truncate,
|
|
73
|
+
utimes,
|
|
74
|
+
watch,
|
|
75
|
+
writeFile
|
|
9
76
|
} from "node:fs/promises";
|
|
10
|
-
import { join as pathJoin } from "node:path";
|
|
77
|
+
import { join as pathJoin, resolve } from "node:path";
|
|
11
78
|
import { copy, copySync } from "./impl/copy.js";
|
|
12
79
|
import { createFile, createFileSync } from "./impl/create-file.js";
|
|
13
80
|
import { diveSync } from "./impl/dive.js";
|
|
@@ -20,7 +87,6 @@ import { pathExists, pathExistsSync } from "./impl/path-exists.js";
|
|
|
20
87
|
import { readFile, readFileSync } from "./impl/read-file.js";
|
|
21
88
|
import { readJson, readJsonSync } from "./impl/read-json.js";
|
|
22
89
|
import { remove, removeSync } from "./impl/remove.js";
|
|
23
|
-
import { writeFile, writeFileSync } from "./impl/write-file.js";
|
|
24
90
|
import { writeJson, writeJsonSync } from "./impl/write-json.js";
|
|
25
91
|
async function* _diveWorker(currentPath, options, currentDepth) {
|
|
26
92
|
const maxDepth = options.depth ?? Number.POSITIVE_INFINITY;
|
|
@@ -115,116 +181,345 @@ const unlink = remove;
|
|
|
115
181
|
const unlinkSync = removeSync;
|
|
116
182
|
const rename = move;
|
|
117
183
|
const renameSync = moveSync;
|
|
184
|
+
const readJSON = readJson;
|
|
185
|
+
const readJSONSync = readJsonSync;
|
|
186
|
+
const writeJSON = writeJson;
|
|
187
|
+
const writeJSONSync = writeJsonSync;
|
|
188
|
+
const outputJSON = outputJson;
|
|
189
|
+
const outputJSONSync = outputJsonSync;
|
|
190
|
+
const cp = copy;
|
|
191
|
+
const cpSync = copySync;
|
|
192
|
+
const exists = pathExists;
|
|
193
|
+
const existsSync = pathExistsSync;
|
|
194
|
+
async function readText(filePath, options = "utf8") {
|
|
195
|
+
return readFile(filePath, options);
|
|
196
|
+
}
|
|
197
|
+
function readTextSync(filePath, options = "utf8") {
|
|
198
|
+
return readFileSync(filePath, options);
|
|
199
|
+
}
|
|
200
|
+
async function readLines(filePath, options = { encoding: "utf8" }) {
|
|
201
|
+
const effectiveOptions = typeof options === "string" ? { encoding: options } : options;
|
|
202
|
+
const contentBuffer = await readFile(filePath, { ...effectiveOptions, encoding: null });
|
|
203
|
+
return contentBuffer.split(/\r?\n/);
|
|
204
|
+
}
|
|
205
|
+
function readLinesSync(filePath, options = { encoding: "utf8" }) {
|
|
206
|
+
const effectiveOptions = typeof options === "string" ? { encoding: options } : options;
|
|
207
|
+
const contentBuffer = readFileSync(filePath, { ...effectiveOptions, encoding: null });
|
|
208
|
+
const content = contentBuffer;
|
|
209
|
+
return content.split(/\r?\n/);
|
|
210
|
+
}
|
|
211
|
+
async function isDirectory(filePath) {
|
|
212
|
+
try {
|
|
213
|
+
const stats = await stat(filePath);
|
|
214
|
+
return stats.isDirectory();
|
|
215
|
+
} catch (error) {
|
|
216
|
+
if (error.code === "ENOENT" || error.code === "ENOTDIR") {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function isDirectorySync(filePath) {
|
|
223
|
+
try {
|
|
224
|
+
const stats = statSync(filePath);
|
|
225
|
+
return stats.isDirectory();
|
|
226
|
+
} catch (error) {
|
|
227
|
+
if (error.code === "ENOENT" || error.code === "ENOTDIR") {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async function isSymlink(filePath) {
|
|
234
|
+
try {
|
|
235
|
+
const stats = await lstat(filePath);
|
|
236
|
+
return stats.isSymbolicLink();
|
|
237
|
+
} catch (error) {
|
|
238
|
+
if (error.code === "ENOENT") {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function isSymlinkSync(filePath) {
|
|
245
|
+
try {
|
|
246
|
+
const stats = lstatSync(filePath);
|
|
247
|
+
return stats.isSymbolicLink();
|
|
248
|
+
} catch (error) {
|
|
249
|
+
if (error.code === "ENOENT") {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
118
255
|
export {
|
|
256
|
+
accessSync,
|
|
257
|
+
appendFileSync,
|
|
258
|
+
chmodSync,
|
|
259
|
+
chownSync,
|
|
260
|
+
closeSync,
|
|
261
|
+
copyFileSync,
|
|
262
|
+
createReadStream,
|
|
263
|
+
createWriteStream,
|
|
264
|
+
fchmodSync,
|
|
265
|
+
fchownSync,
|
|
266
|
+
fdatasyncSync,
|
|
267
|
+
fstatSync,
|
|
268
|
+
fsyncSync,
|
|
269
|
+
ftruncateSync,
|
|
270
|
+
futimesSync,
|
|
271
|
+
lchmodSync,
|
|
272
|
+
lchownSync,
|
|
273
|
+
linkSync,
|
|
274
|
+
lstatSync,
|
|
275
|
+
lutimesSync,
|
|
276
|
+
mkdtempSync,
|
|
277
|
+
openSync,
|
|
278
|
+
opendirSync,
|
|
279
|
+
readFileSync,
|
|
280
|
+
readlinkSync,
|
|
281
|
+
readSync,
|
|
282
|
+
readdirSync,
|
|
283
|
+
realpathSync,
|
|
284
|
+
nodeRenameSync,
|
|
285
|
+
rmSync,
|
|
286
|
+
rmdirSync,
|
|
287
|
+
statSync,
|
|
288
|
+
statfsSync,
|
|
289
|
+
symlinkSync,
|
|
290
|
+
truncateSync,
|
|
291
|
+
nodeUnlinkSync,
|
|
292
|
+
unwatchFile,
|
|
293
|
+
utimesSync,
|
|
294
|
+
watchFile,
|
|
295
|
+
writeFileSync,
|
|
296
|
+
writeSync,
|
|
297
|
+
readvSync,
|
|
298
|
+
writevSync,
|
|
299
|
+
readJsonSync,
|
|
300
|
+
writeJsonSync,
|
|
301
|
+
createFileSync,
|
|
302
|
+
mkdirsSync,
|
|
303
|
+
emptyDirSync,
|
|
304
|
+
pathExistsSync,
|
|
305
|
+
copySync,
|
|
306
|
+
moveSync,
|
|
307
|
+
removeSync,
|
|
308
|
+
outputJsonSync,
|
|
309
|
+
outputFileSync,
|
|
310
|
+
diveSync,
|
|
311
|
+
cpSync,
|
|
312
|
+
ensureDirSync,
|
|
313
|
+
ensureFileSync,
|
|
314
|
+
existsSync,
|
|
315
|
+
mkdirpSync,
|
|
316
|
+
mkdirSync,
|
|
317
|
+
ncpSync,
|
|
318
|
+
outputJSONSync,
|
|
319
|
+
readJSONSync,
|
|
320
|
+
renameSync,
|
|
321
|
+
rimrafSync,
|
|
322
|
+
unlinkSync,
|
|
323
|
+
writeJSONSync,
|
|
324
|
+
isDirectorySync,
|
|
325
|
+
isSymlinkSync,
|
|
326
|
+
readLinesSync,
|
|
327
|
+
readTextSync,
|
|
119
328
|
readJson,
|
|
120
329
|
writeJson,
|
|
121
330
|
createFile,
|
|
122
|
-
writeFile,
|
|
123
|
-
readFile,
|
|
124
331
|
mkdirs,
|
|
125
332
|
emptyDir,
|
|
126
333
|
pathExists,
|
|
127
334
|
copy,
|
|
128
335
|
move,
|
|
129
336
|
remove,
|
|
130
|
-
|
|
131
|
-
|
|
337
|
+
outputJson,
|
|
338
|
+
outputFile,
|
|
132
339
|
access,
|
|
340
|
+
appendFile,
|
|
341
|
+
chmod,
|
|
342
|
+
chown,
|
|
133
343
|
copyFile,
|
|
344
|
+
lchmod,
|
|
345
|
+
lchown,
|
|
346
|
+
link,
|
|
347
|
+
lstat,
|
|
348
|
+
lutimes,
|
|
349
|
+
mkdtemp,
|
|
350
|
+
open,
|
|
351
|
+
opendir,
|
|
352
|
+
readFile,
|
|
353
|
+
readdir,
|
|
354
|
+
readlink,
|
|
355
|
+
realpath,
|
|
356
|
+
nodeRename,
|
|
357
|
+
rm,
|
|
358
|
+
rmdir,
|
|
359
|
+
stat,
|
|
360
|
+
statfs,
|
|
361
|
+
symlink,
|
|
362
|
+
truncate,
|
|
363
|
+
nodeUnlink,
|
|
364
|
+
utimes,
|
|
365
|
+
watch,
|
|
366
|
+
writeFile,
|
|
367
|
+
constants,
|
|
368
|
+
cp,
|
|
369
|
+
ensureDir,
|
|
370
|
+
ensureFile,
|
|
371
|
+
exists,
|
|
372
|
+
mkdir,
|
|
373
|
+
mkdirp,
|
|
374
|
+
ncp,
|
|
375
|
+
outputJSON,
|
|
376
|
+
readJSON,
|
|
377
|
+
rename,
|
|
378
|
+
resolve,
|
|
379
|
+
rimraf,
|
|
380
|
+
unlink,
|
|
381
|
+
writeJSON,
|
|
382
|
+
isDirectory,
|
|
383
|
+
isSymlink,
|
|
384
|
+
readLines,
|
|
385
|
+
readText
|
|
386
|
+
};
|
|
387
|
+
const fs = {
|
|
388
|
+
// Sync direct exports (node:fs)
|
|
389
|
+
accessSync,
|
|
390
|
+
appendFileSync,
|
|
391
|
+
chmodSync,
|
|
392
|
+
chownSync,
|
|
393
|
+
closeSync,
|
|
394
|
+
copyFileSync,
|
|
395
|
+
createReadStream,
|
|
396
|
+
createWriteStream,
|
|
397
|
+
fchmodSync,
|
|
398
|
+
fchownSync,
|
|
399
|
+
fdatasyncSync,
|
|
400
|
+
fstatSync,
|
|
401
|
+
fsyncSync,
|
|
402
|
+
ftruncateSync,
|
|
403
|
+
futimesSync,
|
|
404
|
+
lchmodSync,
|
|
405
|
+
lchownSync,
|
|
406
|
+
linkSync,
|
|
407
|
+
lstatSync,
|
|
408
|
+
lutimesSync,
|
|
409
|
+
mkdtempSync,
|
|
410
|
+
openSync,
|
|
411
|
+
opendirSync,
|
|
412
|
+
readFileSync,
|
|
413
|
+
readlinkSync,
|
|
414
|
+
readSync,
|
|
415
|
+
readdirSync,
|
|
416
|
+
realpathSync,
|
|
417
|
+
nodeRenameSync,
|
|
418
|
+
rmSync,
|
|
419
|
+
rmdirSync,
|
|
420
|
+
statSync,
|
|
421
|
+
statfsSync,
|
|
422
|
+
symlinkSync,
|
|
423
|
+
truncateSync,
|
|
424
|
+
nodeUnlinkSync,
|
|
425
|
+
unwatchFile,
|
|
426
|
+
utimesSync,
|
|
427
|
+
watchFile,
|
|
428
|
+
writeFileSync,
|
|
429
|
+
writeSync,
|
|
430
|
+
readvSync,
|
|
431
|
+
writevSync,
|
|
134
432
|
readJsonSync,
|
|
135
433
|
writeJsonSync,
|
|
136
434
|
createFileSync,
|
|
137
|
-
writeFileSync,
|
|
138
|
-
readFileSync,
|
|
139
435
|
mkdirsSync,
|
|
140
436
|
emptyDirSync,
|
|
141
437
|
pathExistsSync,
|
|
142
438
|
copySync,
|
|
143
439
|
moveSync,
|
|
144
440
|
removeSync,
|
|
145
|
-
readdirSync,
|
|
146
|
-
statSync,
|
|
147
|
-
accessSync,
|
|
148
|
-
constants,
|
|
149
|
-
copyFileSync,
|
|
150
|
-
mkdirp,
|
|
151
|
-
mkdirpSync,
|
|
152
|
-
rimraf,
|
|
153
|
-
rimrafSync,
|
|
154
|
-
ncp,
|
|
155
|
-
ncpSync,
|
|
156
|
-
ensureDir,
|
|
157
|
-
ensureDirSync,
|
|
158
|
-
ensureFile,
|
|
159
|
-
ensureFileSync,
|
|
160
|
-
outputJson,
|
|
161
441
|
outputJsonSync,
|
|
162
|
-
outputFile,
|
|
163
442
|
outputFileSync,
|
|
164
443
|
diveSync,
|
|
165
|
-
|
|
444
|
+
// Sync aliases
|
|
445
|
+
cpSync,
|
|
446
|
+
ensureDirSync,
|
|
447
|
+
ensureFileSync,
|
|
448
|
+
existsSync,
|
|
449
|
+
mkdirpSync,
|
|
166
450
|
mkdirSync,
|
|
167
|
-
|
|
451
|
+
ncpSync,
|
|
452
|
+
outputJSONSync,
|
|
453
|
+
readJSONSync,
|
|
454
|
+
renameSync,
|
|
455
|
+
rimrafSync,
|
|
168
456
|
unlinkSync,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
457
|
+
writeJSONSync,
|
|
458
|
+
// Simple sync custom implementations
|
|
459
|
+
isDirectorySync,
|
|
460
|
+
isSymlinkSync,
|
|
461
|
+
readLinesSync,
|
|
462
|
+
readTextSync,
|
|
463
|
+
// Async direct exports (node:fs/promises)
|
|
174
464
|
readJson,
|
|
175
465
|
writeJson,
|
|
176
466
|
createFile,
|
|
177
|
-
writeFile,
|
|
178
|
-
readFile,
|
|
179
467
|
mkdirs,
|
|
180
468
|
emptyDir,
|
|
181
469
|
pathExists,
|
|
182
470
|
copy,
|
|
183
471
|
move,
|
|
184
472
|
remove,
|
|
185
|
-
|
|
186
|
-
|
|
473
|
+
outputJson,
|
|
474
|
+
outputFile,
|
|
187
475
|
access,
|
|
476
|
+
appendFile,
|
|
477
|
+
chmod,
|
|
478
|
+
chown,
|
|
188
479
|
copyFile,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
480
|
+
lchmod,
|
|
481
|
+
lchown,
|
|
482
|
+
link,
|
|
483
|
+
lstat,
|
|
484
|
+
lutimes,
|
|
485
|
+
mkdtemp,
|
|
486
|
+
open,
|
|
487
|
+
opendir,
|
|
488
|
+
readFile,
|
|
489
|
+
readdir,
|
|
490
|
+
readlink,
|
|
491
|
+
realpath,
|
|
492
|
+
nodeRename,
|
|
493
|
+
rm,
|
|
494
|
+
rmdir,
|
|
495
|
+
stat,
|
|
496
|
+
statfs,
|
|
497
|
+
symlink,
|
|
498
|
+
truncate,
|
|
499
|
+
nodeUnlink,
|
|
500
|
+
utimes,
|
|
501
|
+
watch,
|
|
502
|
+
writeFile,
|
|
503
|
+
// Async aliases
|
|
204
504
|
constants,
|
|
205
|
-
|
|
206
|
-
// alias
|
|
207
|
-
mkdirp,
|
|
208
|
-
mkdirpSync,
|
|
209
|
-
rimraf,
|
|
210
|
-
rimrafSync,
|
|
211
|
-
ncp,
|
|
212
|
-
ncpSync,
|
|
505
|
+
cp,
|
|
213
506
|
ensureDir,
|
|
214
|
-
ensureDirSync,
|
|
215
507
|
ensureFile,
|
|
216
|
-
|
|
217
|
-
outputJson,
|
|
218
|
-
outputJsonSync,
|
|
219
|
-
outputFile,
|
|
220
|
-
outputFileSync,
|
|
221
|
-
dive,
|
|
222
|
-
diveSync,
|
|
508
|
+
exists,
|
|
223
509
|
mkdir,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
510
|
+
mkdirp,
|
|
511
|
+
ncp,
|
|
512
|
+
outputJSON,
|
|
513
|
+
readJSON,
|
|
227
514
|
rename,
|
|
228
|
-
|
|
515
|
+
resolve,
|
|
516
|
+
rimraf,
|
|
517
|
+
unlink,
|
|
518
|
+
writeJSON,
|
|
519
|
+
// Simple async custom implementations
|
|
520
|
+
isDirectory,
|
|
521
|
+
isSymlink,
|
|
522
|
+
readLines,
|
|
523
|
+
readText
|
|
229
524
|
};
|
|
230
525
|
export default fs;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"name": "@reliverse/relifso",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"version": "1.2.
|
|
8
|
+
"version": "1.2.7",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"fs",
|
|
11
11
|
"file",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"klaw-sync": "^7.0.0",
|
|
71
71
|
"knip": "^5.56.0",
|
|
72
72
|
"minimist": "^1.2.8",
|
|
73
|
-
"mocha": "^11.
|
|
73
|
+
"mocha": "^11.4.0",
|
|
74
74
|
"nyc": "^17.1.0",
|
|
75
75
|
"proxyquire": "^2.1.3",
|
|
76
76
|
"read-dir-files": "^0.1.1",
|