@reliverse/relifso 1.2.6 โ 1.2.8
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/README.md +1 -1
- package/bin/mod.d.ts +150 -46
- package/bin/mod.js +365 -85
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
- ๐งฏ Gracefully handles errors like `EMFILE` (reading or writing a lot of files at once) and other edge cases
|
|
13
13
|
- ๐ Consistent error-first behavior โ even for legacy APIs like `fs.exists()`
|
|
14
14
|
- ๐ฆ First-class ESM and full TypeScript support โ no config hacks required
|
|
15
|
-
- ๐งผ Zero bloat โ
|
|
15
|
+
- ๐งผ Zero bloat โ small size ([3.9 kB](https://bundlephobia.com/package/@reliverse/relifso@latest)), zero deps, modern code, no monkey-patching
|
|
16
16
|
- ๐ฏ Supports all Node.js v16+ features โ optimized for Node.js v22+
|
|
17
17
|
- ๐งช **Soon**: Ready for upcoming Node.js v22+ experimental features
|
|
18
18
|
- โ๏ธ **Soon**: Bun v1.2+ ready โ ships with Bun-aware enhancements out of the box
|
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;
|
|
@@ -40,72 +47,169 @@ declare const writeJSON: typeof writeJson;
|
|
|
40
47
|
declare const writeJSONSync: typeof writeJsonSync;
|
|
41
48
|
declare const outputJSON: typeof outputJson;
|
|
42
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;
|
|
43
74
|
export type { CopyOptions } from "./impl/copy.js";
|
|
44
75
|
export type { MoveOptions } from "./impl/move.js";
|
|
45
76
|
export type { ReadFileOptions } from "./impl/read-file.js";
|
|
46
77
|
export type { ReadJsonOptions } from "./impl/read-json.js";
|
|
47
78
|
export type { JsonStringifyOptions } from "./impl/write-json.js";
|
|
48
79
|
export type { WriteJsonOptions } from "./impl/write-json.js";
|
|
49
|
-
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 as ensuredirSync, 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 as ensuredir, ensureDir, ensureFile, exists, mkdir, mkdirp, ncp, outputJSON, readJSON, rename, resolve, rimraf, unlink, writeJSON, isDirectory, isSymlink, readLines, readText, };
|
|
50
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
|
+
ensureDirSync: typeof mkdirsSync;
|
|
140
|
+
ensureFileSync: typeof createFileSync;
|
|
141
|
+
existsSync: typeof pathExistsSync;
|
|
142
|
+
mkdirpSync: typeof mkdirsSync;
|
|
143
|
+
mkdirSync: typeof mkdirsSync;
|
|
144
|
+
ncpSync: typeof copySync;
|
|
145
|
+
outputJSONSync: typeof outputJsonSync;
|
|
146
|
+
readJSONSync: typeof readJsonSync;
|
|
147
|
+
renameSync: typeof moveSync;
|
|
148
|
+
rimrafSync: typeof removeSync;
|
|
149
|
+
unlinkSync: typeof removeSync;
|
|
150
|
+
writeJSONSync: typeof writeJsonSync;
|
|
151
|
+
isDirectorySync: typeof isDirectorySync;
|
|
152
|
+
isSymlinkSync: typeof isSymlinkSync;
|
|
153
|
+
readLinesSync: typeof readLinesSync;
|
|
154
|
+
readTextSync: typeof readTextSync;
|
|
51
155
|
readJson: typeof readJson;
|
|
52
156
|
writeJson: typeof writeJson;
|
|
53
157
|
createFile: typeof createFile;
|
|
54
|
-
writeFile: typeof writeFile;
|
|
55
|
-
readFile: typeof readFile;
|
|
56
158
|
mkdirs: typeof mkdirs;
|
|
57
159
|
emptyDir: typeof emptyDir;
|
|
58
160
|
pathExists: typeof pathExists;
|
|
59
161
|
copy: typeof copy;
|
|
60
162
|
move: typeof move;
|
|
61
163
|
remove: typeof remove;
|
|
62
|
-
|
|
63
|
-
|
|
164
|
+
outputJson: typeof outputJson;
|
|
165
|
+
outputFile: typeof outputFile;
|
|
64
166
|
access: typeof access;
|
|
167
|
+
appendFile: typeof appendFile;
|
|
168
|
+
chmod: typeof chmod;
|
|
169
|
+
chown: typeof chown;
|
|
65
170
|
copyFile: typeof copyFile;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
171
|
+
lchmod: typeof lchmod;
|
|
172
|
+
lchown: typeof lchown;
|
|
173
|
+
link: typeof link;
|
|
174
|
+
lstat: typeof lstat;
|
|
175
|
+
lutimes: typeof lutimes;
|
|
176
|
+
mkdtemp: typeof mkdtemp;
|
|
177
|
+
open: typeof open;
|
|
178
|
+
opendir: typeof opendir;
|
|
179
|
+
readFile: typeof readFile;
|
|
180
|
+
readdir: typeof nodeReaddirInternal;
|
|
181
|
+
readlink: typeof readlink;
|
|
182
|
+
realpath: typeof realpath;
|
|
183
|
+
nodeRename: typeof nodeRename;
|
|
184
|
+
rm: typeof rm;
|
|
185
|
+
rmdir: typeof rmdir;
|
|
186
|
+
stat: typeof nodeStatInternal;
|
|
187
|
+
statfs: typeof statfs;
|
|
188
|
+
symlink: typeof symlink;
|
|
189
|
+
truncate: typeof truncate;
|
|
190
|
+
nodeUnlink: typeof nodeUnlink;
|
|
191
|
+
utimes: typeof utimes;
|
|
192
|
+
watch: typeof watch;
|
|
193
|
+
writeFile: typeof writeFile;
|
|
80
194
|
constants: typeof constants;
|
|
81
|
-
|
|
82
|
-
mkdirp: typeof mkdirs;
|
|
83
|
-
mkdirpSync: typeof mkdirsSync;
|
|
84
|
-
rimraf: typeof remove;
|
|
85
|
-
rimrafSync: typeof removeSync;
|
|
86
|
-
ncp: typeof copy;
|
|
87
|
-
ncpSync: typeof copySync;
|
|
195
|
+
cp: typeof copy;
|
|
88
196
|
ensureDir: typeof mkdirs;
|
|
89
|
-
|
|
197
|
+
ensuredir: typeof mkdirs;
|
|
90
198
|
ensureFile: typeof createFile;
|
|
91
|
-
|
|
92
|
-
outputJson: typeof outputJson;
|
|
93
|
-
outputJsonSync: typeof outputJsonSync;
|
|
94
|
-
outputFile: typeof outputFile;
|
|
95
|
-
outputFileSync: typeof outputFileSync;
|
|
96
|
-
dive: typeof dive;
|
|
97
|
-
diveSync: typeof diveSync;
|
|
199
|
+
exists: typeof pathExists;
|
|
98
200
|
mkdir: typeof mkdirs;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
rename: typeof move;
|
|
103
|
-
renameSync: typeof moveSync;
|
|
201
|
+
mkdirp: typeof mkdirs;
|
|
202
|
+
ncp: typeof copy;
|
|
203
|
+
outputJSON: typeof outputJson;
|
|
104
204
|
readJSON: typeof readJson;
|
|
105
|
-
|
|
205
|
+
rename: typeof move;
|
|
206
|
+
resolve: (...paths: string[]) => string;
|
|
207
|
+
rimraf: typeof remove;
|
|
208
|
+
unlink: typeof remove;
|
|
106
209
|
writeJSON: typeof writeJson;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
210
|
+
isDirectory: typeof isDirectory;
|
|
211
|
+
isSymlink: typeof isSymlink;
|
|
212
|
+
readLines: typeof readLines;
|
|
213
|
+
readText: typeof readText;
|
|
110
214
|
};
|
|
111
215
|
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;
|
|
@@ -121,129 +187,343 @@ const writeJSON = writeJson;
|
|
|
121
187
|
const writeJSONSync = writeJsonSync;
|
|
122
188
|
const outputJSON = outputJson;
|
|
123
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
|
+
}
|
|
124
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 as ensuredirSync,
|
|
313
|
+
ensureDirSync,
|
|
314
|
+
ensureFileSync,
|
|
315
|
+
existsSync,
|
|
316
|
+
mkdirpSync,
|
|
317
|
+
mkdirSync,
|
|
318
|
+
ncpSync,
|
|
319
|
+
outputJSONSync,
|
|
320
|
+
readJSONSync,
|
|
321
|
+
renameSync,
|
|
322
|
+
rimrafSync,
|
|
323
|
+
unlinkSync,
|
|
324
|
+
writeJSONSync,
|
|
325
|
+
isDirectorySync,
|
|
326
|
+
isSymlinkSync,
|
|
327
|
+
readLinesSync,
|
|
328
|
+
readTextSync,
|
|
125
329
|
readJson,
|
|
126
330
|
writeJson,
|
|
127
331
|
createFile,
|
|
128
|
-
writeFile,
|
|
129
|
-
readFile,
|
|
130
332
|
mkdirs,
|
|
131
333
|
emptyDir,
|
|
132
334
|
pathExists,
|
|
133
335
|
copy,
|
|
134
336
|
move,
|
|
135
337
|
remove,
|
|
136
|
-
|
|
137
|
-
|
|
338
|
+
outputJson,
|
|
339
|
+
outputFile,
|
|
138
340
|
access,
|
|
341
|
+
appendFile,
|
|
342
|
+
chmod,
|
|
343
|
+
chown,
|
|
139
344
|
copyFile,
|
|
345
|
+
lchmod,
|
|
346
|
+
lchown,
|
|
347
|
+
link,
|
|
348
|
+
lstat,
|
|
349
|
+
lutimes,
|
|
350
|
+
mkdtemp,
|
|
351
|
+
open,
|
|
352
|
+
opendir,
|
|
353
|
+
readFile,
|
|
354
|
+
readdir,
|
|
355
|
+
readlink,
|
|
356
|
+
realpath,
|
|
357
|
+
nodeRename,
|
|
358
|
+
rm,
|
|
359
|
+
rmdir,
|
|
360
|
+
stat,
|
|
361
|
+
statfs,
|
|
362
|
+
symlink,
|
|
363
|
+
truncate,
|
|
364
|
+
nodeUnlink,
|
|
365
|
+
utimes,
|
|
366
|
+
watch,
|
|
367
|
+
writeFile,
|
|
368
|
+
constants,
|
|
369
|
+
cp,
|
|
370
|
+
ensureDir as ensuredir,
|
|
371
|
+
ensureDir,
|
|
372
|
+
ensureFile,
|
|
373
|
+
exists,
|
|
374
|
+
mkdir,
|
|
375
|
+
mkdirp,
|
|
376
|
+
ncp,
|
|
377
|
+
outputJSON,
|
|
378
|
+
readJSON,
|
|
379
|
+
rename,
|
|
380
|
+
resolve,
|
|
381
|
+
rimraf,
|
|
382
|
+
unlink,
|
|
383
|
+
writeJSON,
|
|
384
|
+
isDirectory,
|
|
385
|
+
isSymlink,
|
|
386
|
+
readLines,
|
|
387
|
+
readText
|
|
388
|
+
};
|
|
389
|
+
const fs = {
|
|
390
|
+
// Sync direct exports (node:fs)
|
|
391
|
+
accessSync,
|
|
392
|
+
appendFileSync,
|
|
393
|
+
chmodSync,
|
|
394
|
+
chownSync,
|
|
395
|
+
closeSync,
|
|
396
|
+
copyFileSync,
|
|
397
|
+
createReadStream,
|
|
398
|
+
createWriteStream,
|
|
399
|
+
fchmodSync,
|
|
400
|
+
fchownSync,
|
|
401
|
+
fdatasyncSync,
|
|
402
|
+
fstatSync,
|
|
403
|
+
fsyncSync,
|
|
404
|
+
ftruncateSync,
|
|
405
|
+
futimesSync,
|
|
406
|
+
lchmodSync,
|
|
407
|
+
lchownSync,
|
|
408
|
+
linkSync,
|
|
409
|
+
lstatSync,
|
|
410
|
+
lutimesSync,
|
|
411
|
+
mkdtempSync,
|
|
412
|
+
openSync,
|
|
413
|
+
opendirSync,
|
|
414
|
+
readFileSync,
|
|
415
|
+
readlinkSync,
|
|
416
|
+
readSync,
|
|
417
|
+
readdirSync,
|
|
418
|
+
realpathSync,
|
|
419
|
+
nodeRenameSync,
|
|
420
|
+
rmSync,
|
|
421
|
+
rmdirSync,
|
|
422
|
+
statSync,
|
|
423
|
+
statfsSync,
|
|
424
|
+
symlinkSync,
|
|
425
|
+
truncateSync,
|
|
426
|
+
nodeUnlinkSync,
|
|
427
|
+
unwatchFile,
|
|
428
|
+
utimesSync,
|
|
429
|
+
watchFile,
|
|
430
|
+
writeFileSync,
|
|
431
|
+
writeSync,
|
|
432
|
+
readvSync,
|
|
433
|
+
writevSync,
|
|
140
434
|
readJsonSync,
|
|
141
435
|
writeJsonSync,
|
|
142
436
|
createFileSync,
|
|
143
|
-
writeFileSync,
|
|
144
|
-
readFileSync,
|
|
145
437
|
mkdirsSync,
|
|
146
438
|
emptyDirSync,
|
|
147
439
|
pathExistsSync,
|
|
148
440
|
copySync,
|
|
149
441
|
moveSync,
|
|
150
442
|
removeSync,
|
|
151
|
-
readdirSync,
|
|
152
|
-
statSync,
|
|
153
|
-
accessSync,
|
|
154
|
-
constants,
|
|
155
|
-
copyFileSync,
|
|
156
|
-
mkdirp,
|
|
157
|
-
mkdirpSync,
|
|
158
|
-
rimraf,
|
|
159
|
-
rimrafSync,
|
|
160
|
-
ncp,
|
|
161
|
-
ncpSync,
|
|
162
|
-
ensureDir,
|
|
163
|
-
ensureDirSync,
|
|
164
|
-
ensureFile,
|
|
165
|
-
ensureFileSync,
|
|
166
|
-
outputJson,
|
|
167
443
|
outputJsonSync,
|
|
168
|
-
outputFile,
|
|
169
444
|
outputFileSync,
|
|
170
445
|
diveSync,
|
|
171
|
-
|
|
446
|
+
// Sync aliases
|
|
447
|
+
cpSync,
|
|
448
|
+
ensuredirSync: ensureDirSync,
|
|
449
|
+
ensureDirSync,
|
|
450
|
+
ensureFileSync,
|
|
451
|
+
existsSync,
|
|
452
|
+
mkdirpSync,
|
|
172
453
|
mkdirSync,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
rename,
|
|
176
|
-
renameSync,
|
|
177
|
-
readJSON,
|
|
454
|
+
ncpSync,
|
|
455
|
+
outputJSONSync,
|
|
178
456
|
readJSONSync,
|
|
179
|
-
|
|
457
|
+
renameSync,
|
|
458
|
+
rimrafSync,
|
|
459
|
+
unlinkSync,
|
|
180
460
|
writeJSONSync,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
461
|
+
// Simple sync custom implementations
|
|
462
|
+
isDirectorySync,
|
|
463
|
+
isSymlinkSync,
|
|
464
|
+
readLinesSync,
|
|
465
|
+
readTextSync,
|
|
466
|
+
// Async direct exports (node:fs/promises)
|
|
186
467
|
readJson,
|
|
187
468
|
writeJson,
|
|
188
469
|
createFile,
|
|
189
|
-
writeFile,
|
|
190
|
-
readFile,
|
|
191
470
|
mkdirs,
|
|
192
471
|
emptyDir,
|
|
193
472
|
pathExists,
|
|
194
473
|
copy,
|
|
195
474
|
move,
|
|
196
475
|
remove,
|
|
197
|
-
|
|
198
|
-
|
|
476
|
+
outputJson,
|
|
477
|
+
outputFile,
|
|
199
478
|
access,
|
|
479
|
+
appendFile,
|
|
480
|
+
chmod,
|
|
481
|
+
chown,
|
|
200
482
|
copyFile,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
483
|
+
lchmod,
|
|
484
|
+
lchown,
|
|
485
|
+
link,
|
|
486
|
+
lstat,
|
|
487
|
+
lutimes,
|
|
488
|
+
mkdtemp,
|
|
489
|
+
open,
|
|
490
|
+
opendir,
|
|
491
|
+
readFile,
|
|
492
|
+
readdir,
|
|
493
|
+
readlink,
|
|
494
|
+
realpath,
|
|
495
|
+
nodeRename,
|
|
496
|
+
rm,
|
|
497
|
+
rmdir,
|
|
498
|
+
stat,
|
|
499
|
+
statfs,
|
|
500
|
+
symlink,
|
|
501
|
+
truncate,
|
|
502
|
+
nodeUnlink,
|
|
503
|
+
utimes,
|
|
504
|
+
watch,
|
|
505
|
+
writeFile,
|
|
506
|
+
// Async aliases
|
|
216
507
|
constants,
|
|
217
|
-
|
|
218
|
-
// alias
|
|
219
|
-
mkdirp,
|
|
220
|
-
mkdirpSync,
|
|
221
|
-
rimraf,
|
|
222
|
-
rimrafSync,
|
|
223
|
-
ncp,
|
|
224
|
-
ncpSync,
|
|
508
|
+
cp,
|
|
225
509
|
ensureDir,
|
|
226
|
-
|
|
510
|
+
ensuredir: ensureDir,
|
|
227
511
|
ensureFile,
|
|
228
|
-
|
|
229
|
-
outputJson,
|
|
230
|
-
outputJsonSync,
|
|
231
|
-
outputFile,
|
|
232
|
-
outputFileSync,
|
|
233
|
-
dive,
|
|
234
|
-
diveSync,
|
|
512
|
+
exists,
|
|
235
513
|
mkdir,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
rename,
|
|
240
|
-
renameSync,
|
|
241
|
-
// ADDED JSON Aliases
|
|
514
|
+
mkdirp,
|
|
515
|
+
ncp,
|
|
516
|
+
outputJSON,
|
|
242
517
|
readJSON,
|
|
243
|
-
|
|
518
|
+
rename,
|
|
519
|
+
resolve,
|
|
520
|
+
rimraf,
|
|
521
|
+
unlink,
|
|
244
522
|
writeJSON,
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
523
|
+
// Simple async custom implementations
|
|
524
|
+
isDirectory,
|
|
525
|
+
isSymlink,
|
|
526
|
+
readLines,
|
|
527
|
+
readText
|
|
248
528
|
};
|
|
249
529
|
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.8",
|
|
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",
|