@reliverse/relifso 1.1.2 → 1.2.0
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 +6 -1
- package/bin/impl/async.d.ts +7 -0
- package/bin/impl/async.js +9 -0
- package/bin/impl/copy.d.ts +20 -0
- package/bin/impl/copy.js +28 -0
- package/bin/impl/create-file.d.ts +1 -0
- package/bin/impl/create-file.js +8 -0
- package/bin/impl/dive.d.ts +17 -0
- package/bin/impl/dive.js +56 -0
- package/bin/impl/empty-dir.d.ts +1 -0
- package/bin/impl/empty-dir.js +10 -0
- package/bin/impl/mkdirs.d.ts +1 -0
- package/bin/impl/mkdirs.js +7 -0
- package/bin/impl/move.d.ts +14 -0
- package/bin/impl/move.js +42 -0
- package/bin/impl/output-file.d.ts +8 -0
- package/bin/impl/output-file.js +8 -0
- package/bin/impl/output-json.d.ts +8 -0
- package/bin/impl/output-json.js +8 -0
- package/bin/impl/path-exists.d.ts +1 -0
- package/bin/impl/path-exists.js +4 -0
- package/bin/impl/read-file.d.ts +12 -0
- package/bin/impl/read-file.js +12 -0
- package/bin/impl/read-json.d.ts +14 -0
- package/bin/impl/read-json.js +24 -0
- package/bin/impl/remove.d.ts +1 -0
- package/bin/impl/remove.js +4 -0
- package/bin/impl/write-file.d.ts +11 -0
- package/bin/impl/write-file.js +9 -0
- package/bin/impl/write-json.d.ts +20 -0
- package/bin/impl/write-json.js +11 -0
- package/bin/mod.d.ts +50 -2
- package/bin/mod.js +158 -2
- package/package.json +7 -9
- package/bin/d.ts.txt +0 -1000
- package/bin/impl/args-impl.d.ts +0 -0
- package/bin/impl/args-impl.js +0 -0
- package/bin/impl/array-polyfill.d.ts +0 -15
- package/bin/impl/external/path-is-inside.d.ts +0 -1
- package/bin/impl/external/path-is-inside.js +0 -16
- package/bin/impl/external/vacuum.d.ts +0 -26
- package/bin/impl/external/vacuum.js +0 -95
- package/bin/impl/fs/dive.d.ts +0 -8
- package/bin/impl/fs/dive.js +0 -91
- package/bin/impl/fs/exists.d.ts +0 -31
- package/bin/impl/fs/exists.js +0 -10
- package/bin/impl/fs/for-each-child.d.ts +0 -34
- package/bin/impl/fs/for-each-child.js +0 -37
- package/bin/impl/fs/index.d.ts +0 -1118
- package/bin/impl/fs/index.js +0 -66
- package/bin/impl/fs/is-directory.d.ts +0 -14
- package/bin/impl/fs/is-directory.js +0 -16
- package/bin/impl/fs/map-children.d.ts +0 -17
- package/bin/impl/fs/map-children.js +0 -31
- package/bin/impl/fs/map-structure.d.ts +0 -35
- package/bin/impl/fs/map-structure.js +0 -44
- package/bin/impl/fs/read-lines.d.ts +0 -16
- package/bin/impl/fs/read-lines.js +0 -32
- package/bin/impl/fs/read-text.d.ts +0 -13
- package/bin/impl/fs/read-text.js +0 -10
- package/bin/impl/fs/universalify.d.ts +0 -18
- package/bin/impl/fs/universalify.js +0 -38
- package/bin/impl/fs/write-file.d.ts +0 -93
- package/bin/impl/fs/write-file.js +0 -47
- package/bin/impl/helpers.d.ts +0 -1
- package/bin/impl/helpers.js +0 -37
- package/bin/impl/json.d.ts +0 -16
- package/bin/impl/json.js +0 -90
- package/bin/impl/lib/copy/copy-sync.d.ts +0 -25
- package/bin/impl/lib/copy/copy-sync.js +0 -119
- package/bin/impl/lib/copy/copy.d.ts +0 -7
- package/bin/impl/lib/copy/copy.js +0 -144
- package/bin/impl/lib/copy/index.d.ts +0 -5
- package/bin/impl/lib/copy/index.js +0 -2
- package/bin/impl/lib/empty/index.d.ts +0 -1
- package/bin/impl/lib/empty/index.js +0 -29
- package/bin/impl/lib/ensure/file.d.ts +0 -2
- package/bin/impl/lib/ensure/file.js +0 -56
- package/bin/impl/lib/ensure/index.d.ts +0 -8
- package/bin/impl/lib/ensure/index.js +0 -12
- package/bin/impl/lib/ensure/link.d.ts +0 -2
- package/bin/impl/lib/ensure/link.js +0 -53
- package/bin/impl/lib/ensure/symlink-paths.d.ts +0 -5
- package/bin/impl/lib/ensure/symlink-paths.js +0 -63
- package/bin/impl/lib/ensure/symlink-type.d.ts +0 -2
- package/bin/impl/lib/ensure/symlink-type.js +0 -23
- package/bin/impl/lib/ensure/symlink.d.ts +0 -2
- package/bin/impl/lib/ensure/symlink.js +0 -59
- package/bin/impl/lib/fs/index.d.ts +0 -1
- package/bin/impl/lib/fs/index.js +0 -1
- package/bin/impl/lib/index.d.ts +0 -15
- package/bin/impl/lib/index.js +0 -34
- package/bin/impl/lib/index_rollup.d.ts +0 -10
- package/bin/impl/lib/index_rollup.js +0 -10
- package/bin/impl/lib/json/index.d.ts +0 -3
- package/bin/impl/lib/json/index.js +0 -10
- package/bin/impl/lib/json/output-json-sync.d.ts +0 -1
- package/bin/impl/lib/json/output-json-sync.js +0 -6
- package/bin/impl/lib/json/output-json.d.ts +0 -1
- package/bin/impl/lib/json/output-json.js +0 -6
- package/bin/impl/lib/mkdirs/index.d.ts +0 -1
- package/bin/impl/lib/mkdirs/index.js +0 -4
- package/bin/impl/lib/mkdirs/make-dir.d.ts +0 -2
- package/bin/impl/lib/mkdirs/make-dir.js +0 -21
- package/bin/impl/lib/mkdirs/utils.d.ts +0 -1
- package/bin/impl/lib/mkdirs/utils.js +0 -13
- package/bin/impl/lib/move/index.d.ts +0 -30
- package/bin/impl/lib/move/index.js +0 -2
- package/bin/impl/lib/move/move-sync.d.ts +0 -8
- package/bin/impl/lib/move/move-sync.js +0 -51
- package/bin/impl/lib/move/move.d.ts +0 -6
- package/bin/impl/lib/move/move.js +0 -48
- package/bin/impl/lib/output-file/index.d.ts +0 -1
- package/bin/impl/lib/output-file/index.js +0 -24
- package/bin/impl/lib/remove/index.d.ts +0 -53
- package/bin/impl/lib/remove/index.js +0 -8
- package/bin/impl/lib/util/stat.d.ts +0 -39
- package/bin/impl/lib/util/stat.js +0 -140
- package/bin/impl/lib/util/utimes.d.ts +0 -7
- package/bin/impl/lib/util/utimes.js +0 -31
- package/bin/impl/subindex.d.ts +0 -38
- package/bin/impl/subindex.js +0 -148
- package/bin/types.d.ts +0 -100
- package/bin/types.js +0 -1
package/bin/impl/lib/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export * from "../fs/index.js";
|
|
2
|
-
export * from "./copy/index.js";
|
|
3
|
-
export * from "./empty/index.js";
|
|
4
|
-
export * from "./ensure/index.js";
|
|
5
|
-
export * from "../json.js";
|
|
6
|
-
export * from "./mkdirs/index.js";
|
|
7
|
-
export * from "./move/index.js";
|
|
8
|
-
export * from "./output-file/index.js";
|
|
9
|
-
export * from "./remove/index.js";
|
|
10
|
-
export { exists } from "../fs/exists.js";
|
|
11
|
-
export { existsSync as pathExistsSync } from "../fs/index.js";
|
|
12
|
-
export { exists as pathExists } from "../fs/exists.js";
|
|
13
|
-
export {
|
|
14
|
-
readJson as readJSON,
|
|
15
|
-
readJsonSync as readJSONSync,
|
|
16
|
-
writeJson as writeJSON,
|
|
17
|
-
writeJsonSync as writeJSONSync,
|
|
18
|
-
outputJson as outputJSON,
|
|
19
|
-
outputJsonSync as outputJSONSync
|
|
20
|
-
} from "../json.js";
|
|
21
|
-
export {
|
|
22
|
-
mkdirs as mkdirp,
|
|
23
|
-
mkdirsSync as mkdirpSync,
|
|
24
|
-
mkdirs as ensureDir,
|
|
25
|
-
mkdirsSync as ensureDirSync
|
|
26
|
-
} from "./mkdirs/index.js";
|
|
27
|
-
export {
|
|
28
|
-
ensureFile as createFile,
|
|
29
|
-
ensureFileSync as createFileSync,
|
|
30
|
-
ensureLink as createLink,
|
|
31
|
-
ensureLinkSync as createLinkSync,
|
|
32
|
-
ensureSymlink as createSymlink,
|
|
33
|
-
ensureSymlinkSync as createSymlinkSync
|
|
34
|
-
} from "./ensure/index.js";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "../fs/index.js";
|
|
2
|
-
export * from "./copy/index.js";
|
|
3
|
-
export * from "./empty/index.js";
|
|
4
|
-
export * from "./ensure/index.js";
|
|
5
|
-
export * from "../json.js";
|
|
6
|
-
export * from "./mkdirs/index.js";
|
|
7
|
-
export * from "./move/index.js";
|
|
8
|
-
export * from "./output-file/index.js";
|
|
9
|
-
export * from "./remove/index.js";
|
|
10
|
-
export { exists } from "../fs/exists.js";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "../fs/index.js";
|
|
2
|
-
export * from "./copy/index.js";
|
|
3
|
-
export * from "./empty/index.js";
|
|
4
|
-
export * from "./ensure/index.js";
|
|
5
|
-
export * from "../json.js";
|
|
6
|
-
export * from "./mkdirs/index.js";
|
|
7
|
-
export * from "./move/index.js";
|
|
8
|
-
export * from "./output-file/index.js";
|
|
9
|
-
export * from "./remove/index.js";
|
|
10
|
-
export { exists } from "../fs/exists.js";
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { writeFile as writeJson, writeFileSync as writeJsonSync, readFile as readJson, readFileSync as readJsonSync, } from "jsonfile";
|
|
2
|
-
export declare const outputJson: (...args: any[]) => Promise<any> | void;
|
|
3
|
-
export { default as outputJsonSync } from "./output-json-sync.js";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { fromPromise as u } from "universalify";
|
|
2
|
-
export {
|
|
3
|
-
writeFile as writeJson,
|
|
4
|
-
writeFileSync as writeJsonSync,
|
|
5
|
-
readFile as readJson,
|
|
6
|
-
readFileSync as readJsonSync
|
|
7
|
-
} from "jsonfile";
|
|
8
|
-
import _outputJson from "./output-json.js";
|
|
9
|
-
export const outputJson = u(_outputJson);
|
|
10
|
-
export { default as outputJsonSync } from "./output-json-sync.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function outputJsonSync(file: any, data: any, options: any): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function outputJson(file: any, data: any, options?: {}): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ensureDir as mkdirs, ensureDirSync as mkdirsSync } from "fs-extra";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { mkdir, mkdirSync } from "../../fs/index.js";
|
|
2
|
-
import { checkPath } from "./utils.js";
|
|
3
|
-
const getMode = (options) => {
|
|
4
|
-
const defaults = { mode: 511 };
|
|
5
|
-
if (typeof options === "number") return options;
|
|
6
|
-
return { ...defaults, ...options }.mode;
|
|
7
|
-
};
|
|
8
|
-
export async function makeDir(dir, options) {
|
|
9
|
-
checkPath(dir);
|
|
10
|
-
return mkdir(dir, {
|
|
11
|
-
mode: getMode(options),
|
|
12
|
-
recursive: true
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export function makeDirSync(dir, options) {
|
|
16
|
-
checkPath(dir);
|
|
17
|
-
return mkdirSync(dir, {
|
|
18
|
-
mode: getMode(options),
|
|
19
|
-
recursive: true
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function checkPath(pth: any): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { parse } from "node:path";
|
|
2
|
-
export function checkPath(pth) {
|
|
3
|
-
if (process.platform === "win32") {
|
|
4
|
-
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(
|
|
5
|
-
pth.replace(parse(pth).root, "")
|
|
6
|
-
);
|
|
7
|
-
if (pathHasInvalidWinCharacters) {
|
|
8
|
-
const error = new Error(`Path contains invalid characters: ${pth}`);
|
|
9
|
-
error.code = "EINVAL";
|
|
10
|
-
throw error;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export { moveSync } from "fs-extra";
|
|
2
|
-
import type { NoParamCallbackWithUndefined } from "fs-extra";
|
|
3
|
-
|
|
4
|
-
interface MoveOptions {
|
|
5
|
-
overwrite?: boolean;
|
|
6
|
-
clobber?: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function move(
|
|
10
|
-
src: string,
|
|
11
|
-
dest: string,
|
|
12
|
-
options: undefined,
|
|
13
|
-
callback: NoParamCallbackWithUndefined,
|
|
14
|
-
): void;
|
|
15
|
-
export function move(
|
|
16
|
-
src: string,
|
|
17
|
-
dest: string,
|
|
18
|
-
options?: MoveOptions,
|
|
19
|
-
): Promise<void>;
|
|
20
|
-
export function move(
|
|
21
|
-
src: string,
|
|
22
|
-
dest: string,
|
|
23
|
-
callback: NoParamCallbackWithUndefined,
|
|
24
|
-
): void;
|
|
25
|
-
export function move(
|
|
26
|
-
src: string,
|
|
27
|
-
dest: string,
|
|
28
|
-
options: MoveOptions,
|
|
29
|
-
callback: NoParamCallbackWithUndefined,
|
|
30
|
-
): void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface MoveOptions {
|
|
2
|
-
/** Overwrite destination if it exists */
|
|
3
|
-
overwrite?: boolean;
|
|
4
|
-
/** Legacy alias for `overwrite`. */
|
|
5
|
-
clobber?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function moveSync(src: string, dest: string, options?: MoveOptions): void;
|
|
8
|
-
export default moveSync;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { existsSync, renameSync } from "graceful-fs";
|
|
2
|
-
import { dirname, parse } from "node:path";
|
|
3
|
-
import { copySync } from "../copy/index.js";
|
|
4
|
-
import { mkdirsSync } from "../mkdirs/index.js";
|
|
5
|
-
import { removeSync } from "../remove/index.js";
|
|
6
|
-
import {
|
|
7
|
-
checkParentPathsSync,
|
|
8
|
-
checkPathsSync
|
|
9
|
-
} from "../util/stat.js";
|
|
10
|
-
export function moveSync(src, dest, options = {}) {
|
|
11
|
-
const overwrite = options.overwrite ?? options.clobber ?? false;
|
|
12
|
-
const { srcStat, isChangingCase = false } = checkPathsSync(
|
|
13
|
-
src,
|
|
14
|
-
dest,
|
|
15
|
-
"move",
|
|
16
|
-
options
|
|
17
|
-
);
|
|
18
|
-
checkParentPathsSync(src, srcStat, dest, "move");
|
|
19
|
-
if (!isRootDir(dirname(dest))) {
|
|
20
|
-
mkdirsSync(dirname(dest), {});
|
|
21
|
-
}
|
|
22
|
-
if (isChangingCase) {
|
|
23
|
-
attemptRename(src, dest, overwrite);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (overwrite) {
|
|
27
|
-
removeSync(dest);
|
|
28
|
-
} else if (existsSync(dest)) {
|
|
29
|
-
throw new Error(`'${dest}' already exists`);
|
|
30
|
-
}
|
|
31
|
-
attemptRename(src, dest, overwrite);
|
|
32
|
-
}
|
|
33
|
-
export default moveSync;
|
|
34
|
-
const isRootDir = (p) => parse(p).root === p;
|
|
35
|
-
function attemptRename(src, dest, overwrite) {
|
|
36
|
-
try {
|
|
37
|
-
renameSync(src, dest);
|
|
38
|
-
} catch (err) {
|
|
39
|
-
const e = err;
|
|
40
|
-
if (e.code !== "EXDEV") throw err;
|
|
41
|
-
moveAcrossDevices(src, dest, overwrite);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function moveAcrossDevices(src, dest, overwrite) {
|
|
45
|
-
copySync(src, dest, {
|
|
46
|
-
overwrite,
|
|
47
|
-
preserveTimestamps: true,
|
|
48
|
-
errorOnExist: true
|
|
49
|
-
});
|
|
50
|
-
removeSync(src);
|
|
51
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { dirname, parse } from "node:path";
|
|
2
|
-
import { fromPromise } from "universalify";
|
|
3
|
-
import { exists as pathExists } from "../../fs/exists.js";
|
|
4
|
-
import { rename as _rename } from "../../fs/index.js";
|
|
5
|
-
import { copy } from "../copy/index.js";
|
|
6
|
-
import { mkdirs } from "../mkdirs/index.js";
|
|
7
|
-
import { remove } from "../remove/index.js";
|
|
8
|
-
import * as stat from "../util/stat.js";
|
|
9
|
-
async function _move(src, dest, opts = {}) {
|
|
10
|
-
const overwrite = opts.overwrite ?? opts.clobber ?? false;
|
|
11
|
-
const { srcStat, isChangingCase = false } = await stat.checkPaths(
|
|
12
|
-
src,
|
|
13
|
-
dest,
|
|
14
|
-
"move",
|
|
15
|
-
opts
|
|
16
|
-
);
|
|
17
|
-
await stat.checkParentPaths(src, srcStat, dest, "move");
|
|
18
|
-
const parent = dirname(dest);
|
|
19
|
-
if (parse(parent).root !== parent) {
|
|
20
|
-
await mkdirs(parent);
|
|
21
|
-
}
|
|
22
|
-
await doRename(src, dest, overwrite, isChangingCase);
|
|
23
|
-
}
|
|
24
|
-
export default fromPromise(_move);
|
|
25
|
-
async function doRename(src, dest, overwrite, isChangingCase) {
|
|
26
|
-
if (!isChangingCase) {
|
|
27
|
-
if (overwrite) {
|
|
28
|
-
await remove(dest);
|
|
29
|
-
} else if (await pathExists(dest)) {
|
|
30
|
-
throw new Error(`'${dest}' already exists`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
await _rename(src, dest);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
const e = err;
|
|
37
|
-
if (e.code !== "EXDEV") throw err;
|
|
38
|
-
await moveAcrossDevices(src, dest, overwrite);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function moveAcrossDevices(src, dest, overwrite) {
|
|
42
|
-
await copy(src, dest, {
|
|
43
|
-
overwrite,
|
|
44
|
-
errorOnExist: true,
|
|
45
|
-
preserveTimestamps: true
|
|
46
|
-
});
|
|
47
|
-
await remove(src);
|
|
48
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { outputFile, outputFileSync } from "fs-extra";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { dirname } from "node:path";
|
|
2
|
-
import { fromPromise } from "universalify";
|
|
3
|
-
import { exists as pathExists } from "../../fs/exists.js";
|
|
4
|
-
import {
|
|
5
|
-
writeFile,
|
|
6
|
-
existsSync,
|
|
7
|
-
writeFileSync
|
|
8
|
-
} from "../../fs/index.js";
|
|
9
|
-
import { mkdirs, mkdirsSync } from "../mkdirs/index.js";
|
|
10
|
-
async function _outputFile(file, data, encoding = "utf-8") {
|
|
11
|
-
const dir = dirname(file);
|
|
12
|
-
if (!await pathExists(dir)) {
|
|
13
|
-
await mkdirs(dir);
|
|
14
|
-
}
|
|
15
|
-
return writeFile(file, data, encoding);
|
|
16
|
-
}
|
|
17
|
-
export const outputFile = fromPromise(_outputFile);
|
|
18
|
-
export function outputFileSync(file, ...args) {
|
|
19
|
-
const dir = dirname(file);
|
|
20
|
-
if (!existsSync(dir)) {
|
|
21
|
-
mkdirsSync(dir);
|
|
22
|
-
}
|
|
23
|
-
writeFileSync(file, ...args);
|
|
24
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type PathLike } from "../../fs/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Removes a file or directory. The directory can have contents. If the path does not exist, silently does nothing.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* import * as fs from 'fs-extra'
|
|
7
|
-
*
|
|
8
|
-
* // remove file
|
|
9
|
-
* // With a callback:
|
|
10
|
-
* fs.remove('/tmp/myfile', err => {
|
|
11
|
-
* if (err) return console.error(err)
|
|
12
|
-
* console.log('success!')
|
|
13
|
-
* })
|
|
14
|
-
*
|
|
15
|
-
* fs.remove('/home/jprichardson', err => {
|
|
16
|
-
* if (err) return console.error(err)
|
|
17
|
-
* console.log('success!') // I just deleted my entire HOME directory.
|
|
18
|
-
* })
|
|
19
|
-
*
|
|
20
|
-
* // With Promises:
|
|
21
|
-
* fs.remove('/tmp/myfile')
|
|
22
|
-
* .then(() => {
|
|
23
|
-
* console.log('success!')
|
|
24
|
-
* })
|
|
25
|
-
* .catch(err => {
|
|
26
|
-
* console.error(err)
|
|
27
|
-
* })
|
|
28
|
-
*
|
|
29
|
-
* // With async/await:
|
|
30
|
-
* async function asyncAwait () {
|
|
31
|
-
* try {
|
|
32
|
-
* await fs.remove('/tmp/myfile')
|
|
33
|
-
* console.log('success!')
|
|
34
|
-
* } catch (err) {
|
|
35
|
-
* console.error(err)
|
|
36
|
-
* }
|
|
37
|
-
* }
|
|
38
|
-
*
|
|
39
|
-
* asyncAwait()
|
|
40
|
-
*/
|
|
41
|
-
export declare const remove: (...args: any[]) => Promise<any> | void;
|
|
42
|
-
/**
|
|
43
|
-
* Removes a file or directory. The directory can have contents. If the path does not exist, silently does nothing.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* import * as fs from 'fs-extra'
|
|
47
|
-
*
|
|
48
|
-
* // remove file
|
|
49
|
-
* fs.removeSync('/tmp/myfile')
|
|
50
|
-
*
|
|
51
|
-
* fs.removeSync('/home/jprichardson') // I just deleted my entire HOME directory.
|
|
52
|
-
*/
|
|
53
|
-
export declare function removeSync(path: PathLike): void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { fromPromise } from "universalify";
|
|
2
|
-
import { rm, rmSync } from "../../fs/index.js";
|
|
3
|
-
export const remove = fromPromise(function remove2(path) {
|
|
4
|
-
return rm(path, { recursive: true, force: true });
|
|
5
|
-
});
|
|
6
|
-
export function removeSync(path) {
|
|
7
|
-
rmSync(path, { recursive: true, force: true });
|
|
8
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {string} src
|
|
3
|
-
* @param {string} dest
|
|
4
|
-
* @param {string} funcName
|
|
5
|
-
* @param {{ dereference?: boolean }} opts
|
|
6
|
-
*/
|
|
7
|
-
export declare function checkPathsSync(src: any, dest: any, funcName: any, opts: any): {
|
|
8
|
-
srcStat: any;
|
|
9
|
-
destStat: any;
|
|
10
|
-
isChangingCase: boolean;
|
|
11
|
-
} | {
|
|
12
|
-
srcStat: any;
|
|
13
|
-
destStat: any;
|
|
14
|
-
isChangingCase?: undefined;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {string} src
|
|
19
|
-
* @param {import('fs').BigIntStats} srcStat
|
|
20
|
-
* @param {string} dest
|
|
21
|
-
* @param {string} funcName
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
export declare function checkParentPathsSync(src: any, srcStat: any, dest: any, funcName: any): void;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param {import('fs').BigIntStats} srcStat
|
|
28
|
-
* @param {import('fs').BigIntStats} destStat
|
|
29
|
-
* @returns {boolean}
|
|
30
|
-
*/
|
|
31
|
-
export declare function areIdentical(srcStat: any, destStat: any): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* @param {string} src
|
|
34
|
-
* @param {string} dest
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
export declare function isSrcSubdir(src: any, dest: any): boolean;
|
|
38
|
-
export declare const checkPaths: (...args: any[]) => Promise<any> | void;
|
|
39
|
-
export declare const checkParentPaths: (...args: any[]) => Promise<any> | void;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { basename, resolve, dirname, parse, sep } from "node:path";
|
|
2
|
-
import { fromPromise } from "universalify";
|
|
3
|
-
import {
|
|
4
|
-
stat,
|
|
5
|
-
lstat,
|
|
6
|
-
statSync,
|
|
7
|
-
lstatSync
|
|
8
|
-
} from "../../fs/index.js";
|
|
9
|
-
async function getStats(src, dest, opts) {
|
|
10
|
-
const statFunc = opts.dereference ? (file) => stat(file, { bigint: true }) : (file) => lstat(file, { bigint: true });
|
|
11
|
-
const [srcStat, destStat] = await Promise.all([
|
|
12
|
-
statFunc(src),
|
|
13
|
-
statFunc(dest).catch((err) => {
|
|
14
|
-
if (err.code === "ENOENT") return null;
|
|
15
|
-
throw err;
|
|
16
|
-
})
|
|
17
|
-
]);
|
|
18
|
-
return { srcStat, destStat };
|
|
19
|
-
}
|
|
20
|
-
function getStatsSync(src, dest, opts) {
|
|
21
|
-
let destStat;
|
|
22
|
-
const statFunc = opts.dereference ? (file) => statSync(file, { bigint: true }) : (file) => lstatSync(file, { bigint: true });
|
|
23
|
-
const srcStat = statFunc(src);
|
|
24
|
-
try {
|
|
25
|
-
destStat = statFunc(dest);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
if (
|
|
28
|
-
/** @type {NodeJS.ErrnoException} */
|
|
29
|
-
err.code === "ENOENT"
|
|
30
|
-
)
|
|
31
|
-
return { srcStat, destStat: null };
|
|
32
|
-
throw err;
|
|
33
|
-
}
|
|
34
|
-
return { srcStat, destStat };
|
|
35
|
-
}
|
|
36
|
-
async function _checkPaths(src, dest, funcName, opts) {
|
|
37
|
-
const { srcStat, destStat } = await getStats(src, dest, opts);
|
|
38
|
-
if (destStat) {
|
|
39
|
-
if (areIdentical(srcStat, destStat)) {
|
|
40
|
-
const srcBaseName = basename(src);
|
|
41
|
-
const destBaseName = basename(dest);
|
|
42
|
-
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
43
|
-
return { srcStat, destStat, isChangingCase: true };
|
|
44
|
-
}
|
|
45
|
-
throw new Error("Source and destination must not be the same.");
|
|
46
|
-
}
|
|
47
|
-
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Cannot overwrite non-directory '${dest}' with directory '${src}'.`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Cannot overwrite directory '${dest}' with non-directory '${src}'.`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
59
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
60
|
-
}
|
|
61
|
-
return { srcStat, destStat };
|
|
62
|
-
}
|
|
63
|
-
export function checkPathsSync(src, dest, funcName, opts) {
|
|
64
|
-
const { srcStat, destStat } = getStatsSync(src, dest, opts);
|
|
65
|
-
if (destStat) {
|
|
66
|
-
if (areIdentical(srcStat, destStat)) {
|
|
67
|
-
const srcBaseName = basename(src);
|
|
68
|
-
const destBaseName = basename(dest);
|
|
69
|
-
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
70
|
-
return { srcStat, destStat, isChangingCase: true };
|
|
71
|
-
}
|
|
72
|
-
throw new Error("Source and destination must not be the same.");
|
|
73
|
-
}
|
|
74
|
-
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
75
|
-
throw new Error(
|
|
76
|
-
`Cannot overwrite non-directory '${dest}' with directory '${src}'.`
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
80
|
-
throw new Error(
|
|
81
|
-
`Cannot overwrite directory '${dest}' with non-directory '${src}'.`
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
86
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
87
|
-
}
|
|
88
|
-
return { srcStat, destStat };
|
|
89
|
-
}
|
|
90
|
-
async function _checkParentPaths(src, srcStat, dest, funcName) {
|
|
91
|
-
const srcParent = resolve(dirname(src));
|
|
92
|
-
const destParent = resolve(dirname(dest));
|
|
93
|
-
if (destParent === srcParent || destParent === parse(destParent).root) return;
|
|
94
|
-
let destStat;
|
|
95
|
-
try {
|
|
96
|
-
destStat = await stat(destParent, { bigint: true });
|
|
97
|
-
} catch (err) {
|
|
98
|
-
if (
|
|
99
|
-
/** @type {NodeJS.ErrnoException} */
|
|
100
|
-
err.code === "ENOENT"
|
|
101
|
-
) return;
|
|
102
|
-
throw err;
|
|
103
|
-
}
|
|
104
|
-
if (areIdentical(srcStat, destStat)) {
|
|
105
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
106
|
-
}
|
|
107
|
-
return checkParentPaths(src, srcStat, destParent, funcName);
|
|
108
|
-
}
|
|
109
|
-
export function checkParentPathsSync(src, srcStat, dest, funcName) {
|
|
110
|
-
const srcParent = resolve(dirname(src));
|
|
111
|
-
const destParent = resolve(dirname(dest));
|
|
112
|
-
if (destParent === srcParent || destParent === parse(destParent).root) return;
|
|
113
|
-
let destStat;
|
|
114
|
-
try {
|
|
115
|
-
destStat = statSync(destParent, { bigint: true });
|
|
116
|
-
} catch (err) {
|
|
117
|
-
if (
|
|
118
|
-
/** @type {NodeJS.ErrnoException} */
|
|
119
|
-
err.code === "ENOENT"
|
|
120
|
-
) return;
|
|
121
|
-
throw err;
|
|
122
|
-
}
|
|
123
|
-
if (areIdentical(srcStat, destStat)) {
|
|
124
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
125
|
-
}
|
|
126
|
-
return checkParentPathsSync(src, srcStat, destParent, funcName);
|
|
127
|
-
}
|
|
128
|
-
export function areIdentical(srcStat, destStat) {
|
|
129
|
-
return !!destStat.ino && !!destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
|
|
130
|
-
}
|
|
131
|
-
export function isSrcSubdir(src, dest) {
|
|
132
|
-
const srcArr = resolve(src).split(sep).filter((i) => i);
|
|
133
|
-
const destArr = resolve(dest).split(sep).filter((i) => i);
|
|
134
|
-
return srcArr.every((cur, i) => destArr[i] === cur);
|
|
135
|
-
}
|
|
136
|
-
function errMsg(src, dest, funcName) {
|
|
137
|
-
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
|
|
138
|
-
}
|
|
139
|
-
export const checkPaths = fromPromise(_checkPaths);
|
|
140
|
-
export const checkParentPaths = fromPromise(_checkParentPaths);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {import("fs").PathLike} path
|
|
3
|
-
* @param {import("fs").TimeLike} atime
|
|
4
|
-
* @param {import("fs").TimeLike} mtime
|
|
5
|
-
*/
|
|
6
|
-
export declare function utimesMillisSync(path: any, atime: any, mtime: any): any;
|
|
7
|
-
export declare const utimesMillis: (...args: any[]) => Promise<any> | void;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { fromPromise } from "universalify";
|
|
2
|
-
import {
|
|
3
|
-
futimes,
|
|
4
|
-
open,
|
|
5
|
-
close,
|
|
6
|
-
openSync,
|
|
7
|
-
futimesSync,
|
|
8
|
-
closeSync
|
|
9
|
-
} from "../../fs/index.js";
|
|
10
|
-
async function _utimesMillis(path, atime, mtime) {
|
|
11
|
-
const fd = await open(path, "r+");
|
|
12
|
-
let closeErr = null;
|
|
13
|
-
try {
|
|
14
|
-
await futimes(fd, atime, mtime);
|
|
15
|
-
} finally {
|
|
16
|
-
try {
|
|
17
|
-
await close(fd);
|
|
18
|
-
} catch (e) {
|
|
19
|
-
closeErr = e;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (closeErr) {
|
|
23
|
-
throw closeErr;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export function utimesMillisSync(path, atime, mtime) {
|
|
27
|
-
const fd = openSync(path, "r+");
|
|
28
|
-
futimesSync(fd, atime, mtime);
|
|
29
|
-
return closeSync(fd);
|
|
30
|
-
}
|
|
31
|
-
export const utimesMillis = fromPromise(_utimesMillis);
|
package/bin/impl/subindex.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export type * from "../types.js";
|
|
2
|
-
export type { CopyOptions, CopyOptionsSync, EnsureDirOptions, SymlinkType, MoveOptions, JsonOutputOptions, } from "fs-extra";
|
|
3
|
-
export * from "./fs/index.js";
|
|
4
|
-
export { access, appendFile, chmod, chown, close, copyFile, cp, createReadStream, createWriteStream, fchmod, fchown, fdatasync, fstat, ftruncate, futimes, lchmod, lchown, link, lstat, lutimes, mkdir, mkdtemp, open, openAsBlob, opendir, read, readFile, readv, readdir, realpath, rename, rm, rmdir, stat, statfs, symlink, truncate, unlink, unwatchFile, utimes, watch, watchFile, write, writev, accessSync, appendFileSync, chmodSync, chownSync, closeSync, copyFileSync, cpSync, existsSync, fchmodSync, fchownSync, fdatasyncSync, fstatSync, fsync, fsyncSync, ftruncateSync, futimesSync, lchmodSync, lchownSync, linkSync, lstatSync, lutimesSync, mkdirSync, mkdtempSync, openSync, opendirSync, readSync, readFileSync, readlinkSync, readvSync, readdirSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, statfsSync, symlinkSync, truncateSync, unlinkSync, utimesSync, writeFileSync, writeSync, writevSync } from "./fs/index.js";
|
|
5
|
-
export { default as vacuum } from "./external/vacuum.js";
|
|
6
|
-
export { copy, copySync } from "./lib/copy/index.js";
|
|
7
|
-
export { emptyDir, emptyDirSync } from "./lib/empty/index.js";
|
|
8
|
-
export { ensureFile, ensureFileSync, ensureLink, ensureLinkSync, ensureSymlink, ensureSymlinkSync, } from "./lib/ensure/index.js";
|
|
9
|
-
export { mkdirs, mkdirsSync, mkdirs as ensureDir, mkdirsSync as ensureDirSync, } from "./lib/mkdirs/index.js";
|
|
10
|
-
export { move, moveSync } from "./lib/move/index.js";
|
|
11
|
-
export { outputFile, outputFileSync } from "./lib/output-file/index.js";
|
|
12
|
-
export { remove, removeSync } from "./lib/remove/index.js";
|
|
13
|
-
export { exists, exists as pathExists } from "./fs/exists.js";
|
|
14
|
-
export { dive, diveSync } from "./fs/dive.js";
|
|
15
|
-
export { forEachChild, forEachChildSync } from "./fs/for-each-child.js";
|
|
16
|
-
export { isDirectory, isDirectorySync } from "./fs/is-directory.js";
|
|
17
|
-
export { mapChildren } from "./fs/map-children.js";
|
|
18
|
-
export { mapStructure, mapStructureOrdered } from "./fs/map-structure.js";
|
|
19
|
-
export { readLines, readLinesSync } from "./fs/read-lines.js";
|
|
20
|
-
export { readText, readTextSync } from "./fs/read-text.js";
|
|
21
|
-
export { writeFile } from "./fs/write-file.js";
|
|
22
|
-
export * from "./json.js";
|
|
23
|
-
/**
|
|
24
|
-
* Resolve a child file of a folder.
|
|
25
|
-
* @param path The parent folder path
|
|
26
|
-
* @param child The child filesystem entry path (can be a file or folder)
|
|
27
|
-
* @returns `path` and `child` concatenated, delimited by whatever path separator is already used in the string,
|
|
28
|
-
* defaulting to `/`; a delimiter is never added if it's not necessary.
|
|
29
|
-
*/
|
|
30
|
-
export declare function resolve(path: string, child: string): string;
|
|
31
|
-
/**
|
|
32
|
-
* Check if the file at a path is a symbolic link.
|
|
33
|
-
* @param path the path to the file to check
|
|
34
|
-
* @param callback callback function to call with whether or not the file is a symbolic link, or a value for `err` if the
|
|
35
|
-
* operation fails
|
|
36
|
-
*/
|
|
37
|
-
export declare function isSymlink(file: string): Promise<boolean>;
|
|
38
|
-
export declare function isSymlink(file: string, callback?: (err: NodeJS.ErrnoException | null, isSymblink?: boolean) => void): void;
|