@reliverse/relifso 1.1.3 → 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.
Files changed (124) hide show
  1. package/README.md +6 -1
  2. package/bin/impl/async.d.ts +7 -0
  3. package/bin/impl/async.js +9 -0
  4. package/bin/impl/copy.d.ts +20 -0
  5. package/bin/impl/copy.js +28 -0
  6. package/bin/impl/create-file.d.ts +1 -0
  7. package/bin/impl/create-file.js +8 -0
  8. package/bin/impl/dive.d.ts +17 -0
  9. package/bin/impl/dive.js +56 -0
  10. package/bin/impl/empty-dir.d.ts +1 -0
  11. package/bin/impl/empty-dir.js +10 -0
  12. package/bin/impl/mkdirs.d.ts +1 -0
  13. package/bin/impl/mkdirs.js +7 -0
  14. package/bin/impl/move.d.ts +14 -0
  15. package/bin/impl/move.js +42 -0
  16. package/bin/impl/output-file.d.ts +8 -0
  17. package/bin/impl/output-file.js +8 -0
  18. package/bin/impl/output-json.d.ts +8 -0
  19. package/bin/impl/output-json.js +8 -0
  20. package/bin/impl/path-exists.d.ts +1 -0
  21. package/bin/impl/path-exists.js +4 -0
  22. package/bin/impl/read-file.d.ts +12 -0
  23. package/bin/impl/read-file.js +12 -0
  24. package/bin/impl/read-json.d.ts +14 -0
  25. package/bin/impl/read-json.js +24 -0
  26. package/bin/impl/remove.d.ts +1 -0
  27. package/bin/impl/remove.js +4 -0
  28. package/bin/impl/write-file.d.ts +11 -0
  29. package/bin/impl/write-file.js +9 -0
  30. package/bin/impl/write-json.d.ts +20 -0
  31. package/bin/impl/write-json.js +11 -0
  32. package/bin/mod.d.ts +50 -2
  33. package/bin/mod.js +158 -2
  34. package/package.json +6 -8
  35. package/bin/d.ts.txt +0 -1000
  36. package/bin/impl/args-impl.d.ts +0 -0
  37. package/bin/impl/args-impl.js +0 -0
  38. package/bin/impl/array-polyfill.d.ts +0 -15
  39. package/bin/impl/external/path-is-inside.d.ts +0 -1
  40. package/bin/impl/external/path-is-inside.js +0 -16
  41. package/bin/impl/external/vacuum.d.ts +0 -26
  42. package/bin/impl/external/vacuum.js +0 -95
  43. package/bin/impl/fs/dive.d.ts +0 -8
  44. package/bin/impl/fs/dive.js +0 -91
  45. package/bin/impl/fs/exists.d.ts +0 -31
  46. package/bin/impl/fs/exists.js +0 -10
  47. package/bin/impl/fs/for-each-child.d.ts +0 -34
  48. package/bin/impl/fs/for-each-child.js +0 -37
  49. package/bin/impl/fs/index.d.ts +0 -1118
  50. package/bin/impl/fs/index.js +0 -66
  51. package/bin/impl/fs/is-directory.d.ts +0 -14
  52. package/bin/impl/fs/is-directory.js +0 -16
  53. package/bin/impl/fs/map-children.d.ts +0 -17
  54. package/bin/impl/fs/map-children.js +0 -31
  55. package/bin/impl/fs/map-structure.d.ts +0 -35
  56. package/bin/impl/fs/map-structure.js +0 -44
  57. package/bin/impl/fs/read-lines.d.ts +0 -16
  58. package/bin/impl/fs/read-lines.js +0 -32
  59. package/bin/impl/fs/read-text.d.ts +0 -13
  60. package/bin/impl/fs/read-text.js +0 -10
  61. package/bin/impl/fs/universalify.d.ts +0 -18
  62. package/bin/impl/fs/universalify.js +0 -38
  63. package/bin/impl/fs/write-file.d.ts +0 -93
  64. package/bin/impl/fs/write-file.js +0 -47
  65. package/bin/impl/helpers.d.ts +0 -1
  66. package/bin/impl/helpers.js +0 -37
  67. package/bin/impl/json.d.ts +0 -16
  68. package/bin/impl/json.js +0 -90
  69. package/bin/impl/lib/copy/copy-sync.d.ts +0 -25
  70. package/bin/impl/lib/copy/copy-sync.js +0 -119
  71. package/bin/impl/lib/copy/copy.d.ts +0 -7
  72. package/bin/impl/lib/copy/copy.js +0 -144
  73. package/bin/impl/lib/copy/index.d.ts +0 -5
  74. package/bin/impl/lib/copy/index.js +0 -2
  75. package/bin/impl/lib/empty/index.d.ts +0 -1
  76. package/bin/impl/lib/empty/index.js +0 -29
  77. package/bin/impl/lib/ensure/file.d.ts +0 -2
  78. package/bin/impl/lib/ensure/file.js +0 -56
  79. package/bin/impl/lib/ensure/index.d.ts +0 -8
  80. package/bin/impl/lib/ensure/index.js +0 -12
  81. package/bin/impl/lib/ensure/link.d.ts +0 -2
  82. package/bin/impl/lib/ensure/link.js +0 -53
  83. package/bin/impl/lib/ensure/symlink-paths.d.ts +0 -5
  84. package/bin/impl/lib/ensure/symlink-paths.js +0 -63
  85. package/bin/impl/lib/ensure/symlink-type.d.ts +0 -2
  86. package/bin/impl/lib/ensure/symlink-type.js +0 -23
  87. package/bin/impl/lib/ensure/symlink.d.ts +0 -2
  88. package/bin/impl/lib/ensure/symlink.js +0 -59
  89. package/bin/impl/lib/fs/index.d.ts +0 -1
  90. package/bin/impl/lib/fs/index.js +0 -1
  91. package/bin/impl/lib/index.d.ts +0 -15
  92. package/bin/impl/lib/index.js +0 -34
  93. package/bin/impl/lib/index_rollup.d.ts +0 -10
  94. package/bin/impl/lib/index_rollup.js +0 -10
  95. package/bin/impl/lib/json/index.d.ts +0 -3
  96. package/bin/impl/lib/json/index.js +0 -10
  97. package/bin/impl/lib/json/output-json-sync.d.ts +0 -1
  98. package/bin/impl/lib/json/output-json-sync.js +0 -6
  99. package/bin/impl/lib/json/output-json.d.ts +0 -1
  100. package/bin/impl/lib/json/output-json.js +0 -6
  101. package/bin/impl/lib/mkdirs/index.d.ts +0 -1
  102. package/bin/impl/lib/mkdirs/index.js +0 -4
  103. package/bin/impl/lib/mkdirs/make-dir.d.ts +0 -2
  104. package/bin/impl/lib/mkdirs/make-dir.js +0 -21
  105. package/bin/impl/lib/mkdirs/utils.d.ts +0 -1
  106. package/bin/impl/lib/mkdirs/utils.js +0 -13
  107. package/bin/impl/lib/move/index.d.ts +0 -30
  108. package/bin/impl/lib/move/index.js +0 -2
  109. package/bin/impl/lib/move/move-sync.d.ts +0 -8
  110. package/bin/impl/lib/move/move-sync.js +0 -51
  111. package/bin/impl/lib/move/move.d.ts +0 -6
  112. package/bin/impl/lib/move/move.js +0 -48
  113. package/bin/impl/lib/output-file/index.d.ts +0 -1
  114. package/bin/impl/lib/output-file/index.js +0 -24
  115. package/bin/impl/lib/remove/index.d.ts +0 -53
  116. package/bin/impl/lib/remove/index.js +0 -8
  117. package/bin/impl/lib/util/stat.d.ts +0 -39
  118. package/bin/impl/lib/util/stat.js +0 -140
  119. package/bin/impl/lib/util/utimes.d.ts +0 -7
  120. package/bin/impl/lib/util/utimes.js +0 -31
  121. package/bin/impl/subindex.d.ts +0 -43
  122. package/bin/impl/subindex.js +0 -161
  123. package/bin/types.d.ts +0 -100
  124. package/bin/types.js +0 -1
File without changes
File without changes
@@ -1,15 +0,0 @@
1
- // https://github.com/microsoft/TypeScript/issues/50803
2
- interface ArrayConstructor {
3
- fromAsync<T>(
4
- iterableOrArrayLike:
5
- | AsyncIterable<T>
6
- | Iterable<T | Promise<T>>
7
- | ArrayLike<T | Promise<T>>,
8
- ): Promise<T[]>;
9
-
10
- fromAsync<T, U>(
11
- iterableOrArrayLike: AsyncIterable<T> | Iterable<T> | ArrayLike<T>,
12
- mapFn: (value: Awaited<T>) => U,
13
- thisArg?: any,
14
- ): Promise<Awaited<U>[]>;
15
- }
@@ -1 +0,0 @@
1
- export default function (thePath: string, potentialParent: string): boolean;
@@ -1,16 +0,0 @@
1
- import { sep } from "node:path";
2
- export default function(thePath, potentialParent) {
3
- thePath = stripTrailingSep(thePath);
4
- potentialParent = stripTrailingSep(potentialParent);
5
- if (process.platform === "win32") {
6
- thePath = thePath.toLowerCase();
7
- potentialParent = potentialParent.toLowerCase();
8
- }
9
- return thePath.lastIndexOf(potentialParent, 0) === 0 && (thePath[potentialParent.length] === sep || thePath[potentialParent.length] === void 0);
10
- }
11
- function stripTrailingSep(thePath) {
12
- if (thePath[thePath.length - 1] === sep) {
13
- return thePath.slice(0, -1);
14
- }
15
- return thePath;
16
- }
@@ -1,26 +0,0 @@
1
- import type { VacuumOptions, ErrorCallback } from "../../types.js";
2
- /**
3
- * Remove the empty branches of a directory tree, optionally up to (but not including) a specified base directory.
4
- * Optionally nukes the leaf directory.
5
- * @param directory Leaf node to remove. **Must be a directory, symlink, or file.**
6
- * @param options Options for `fs-vacuum`.
7
- * @param callback Function to call once vacuuming is complete.
8
- * @example ```
9
- * var logger = require("npmlog");
10
- * var vacuum = require("fs-vacuum");
11
- *
12
- * var options = {
13
- * base : "/path/to/my/tree/root",
14
- * purge : true,
15
- * log : logger.silly.bind(logger, "myCleanup")
16
- * };
17
- *
18
- * // Assuming there are no other files or directories in "out", "to", or "my",
19
- * // the final path will just be "/path/to/my/tree/root".
20
- * vacuum("/path/to/my/tree/root/out/to/my/files", function (error) {
21
- * if (error) console.error("Unable to cleanly vacuum:", error.message);
22
- * });
23
- * ```
24
- */
25
- export default function vacuum(directory: string, options?: VacuumOptions): Promise<void>;
26
- export default function vacuum(directory: string, options?: VacuumOptions, callback?: ErrorCallback): void;
@@ -1,95 +0,0 @@
1
- import { lstat, readdir, unlink, rm, rmdir } from "graceful-fs";
2
- import assert from "node:assert";
3
- import { dirname } from "node:path";
4
- import { resolve } from "node:path";
5
- import isInside from "./path-is-inside.js";
6
- const noop = () => {
7
- };
8
- export default function vacuum(leaf, options = {}, cb) {
9
- if (cb === void 0) {
10
- return new Promise((resolve2, reject) => {
11
- vacuum(leaf, options, (err) => err ? reject(err) : resolve2());
12
- });
13
- }
14
- assert(typeof leaf === "string", "must pass in path to remove");
15
- assert(typeof options === "object", "options must be an object");
16
- assert(typeof cb === "function", "must pass in callback");
17
- const log = options.log ?? noop;
18
- leaf = leaf && resolve(leaf);
19
- const base = options.base && resolve(options.base);
20
- if (base && !isInside(leaf, base)) {
21
- return cb(new Error(`${leaf} is not a child of ${base}`));
22
- }
23
- lstat(leaf, (error, stat) => {
24
- if (error) {
25
- if (error.code === "ENOENT") return cb(null);
26
- log(error.stack);
27
- return cb(error);
28
- }
29
- if (!(stat && (stat.isDirectory() || stat.isSymbolicLink() || stat.isFile()))) {
30
- log(`${leaf} is not a directory, file, or link`);
31
- return cb(new Error(`${leaf} is not a directory, file, or link`));
32
- }
33
- if (options.purge) {
34
- log("purging", leaf);
35
- rm(leaf, { recursive: true, force: true }, (error2) => {
36
- if (error2) return cb(error2);
37
- next(dirname(leaf));
38
- });
39
- } else if (!stat.isDirectory()) {
40
- log("removing", leaf);
41
- unlink(leaf, (error2) => {
42
- if (error2) return cb(error2);
43
- next(dirname(leaf));
44
- });
45
- } else {
46
- next(leaf);
47
- }
48
- });
49
- function next(branch) {
50
- branch = branch && resolve(branch);
51
- if (base && branch === base || branch === dirname(branch)) {
52
- log("finished vacuuming up to", branch);
53
- return cb(null);
54
- }
55
- readdir(branch, (error, files) => {
56
- if (error) {
57
- if (error.code === "ENOENT") return cb(null);
58
- log("unable to check directory", branch, "due to", error.message);
59
- return cb(error);
60
- }
61
- if (files.length > 0) {
62
- log("quitting because other entries in", branch);
63
- return cb(null);
64
- }
65
- if (branch === process.env.HOME) {
66
- log("quitting because cannot remove home directory", branch);
67
- return cb(null);
68
- }
69
- log("removing", branch);
70
- lstat(branch, (error2, stat) => {
71
- if (error2) {
72
- if (error2.code === "ENOENT") return cb(null);
73
- log("unable to lstat", branch, "due to", error2.message);
74
- return cb(error2);
75
- }
76
- const remove = stat.isDirectory() ? rmdir : unlink;
77
- remove(branch, (error3) => {
78
- if (error3) {
79
- if (error3.code === "ENOENT") {
80
- log("quitting because lost the race to remove", branch);
81
- return cb(null);
82
- }
83
- if (error3.code === "ENOTEMPTY" || error3.code === "EEXIST") {
84
- log("quitting because new (racy) entries in", branch);
85
- return cb(null);
86
- }
87
- log("unable to remove", branch, "due to", error3.message);
88
- return cb(error3);
89
- }
90
- next(dirname(branch));
91
- });
92
- });
93
- });
94
- }
95
- }
@@ -1,8 +0,0 @@
1
- import type { DiveActionCallback, DiveActionPromise, DiveOptions } from '../../types.js';
2
- import * as fs from './index.js';
3
- export declare function _diveWorker(directory: string, options?: DiveOptions): AsyncGenerator<[file: string, stat: fs.Stats]>;
4
- export declare function dive(directory: string, options: DiveOptions, action: DiveActionCallback, complete: () => void): void;
5
- export declare function dive(directory: string, options: DiveOptions, action: DiveActionPromise): Promise<void>;
6
- export declare function dive(directory: string, action: DiveActionCallback, complete: () => void): void;
7
- export declare function dive(directory: string, action: DiveActionPromise): Promise<void>;
8
- export declare function diveSync(directory: string, options?: DiveOptions): string[];
@@ -1,91 +0,0 @@
1
- import { resolve as pathResolve } from "node:path";
2
- import * as fs from "./index.js";
3
- const DEFAULT_OPTS = { recursive: true, all: true, files: true };
4
- const matches = (str, test) => test ? typeof test === "string" ? str.includes(test) : test.test(str) : false;
5
- export async function* _diveWorker(directory, options = {}) {
6
- const opts = { ...DEFAULT_OPTS, ...options };
7
- const children = await fs.readdir(directory, { withFileTypes: true });
8
- if (children.length === 0 && opts.directories) {
9
- yield [directory, await fs.stat(directory)];
10
- }
11
- for (const dirent of children) {
12
- if (!opts.all && dirent.name.startsWith(".")) continue;
13
- const path = pathResolve(dirent.path ?? directory, dirent.name);
14
- if (opts.ignore && matches(path, opts.ignore)) continue;
15
- if (dirent.isDirectory()) {
16
- if (opts.recursive) {
17
- yield* _diveWorker(path, opts);
18
- } else if (opts.directories) {
19
- yield [path, await fs.stat(path)];
20
- }
21
- } else if (opts.files) {
22
- yield [path, await fs.stat(path)];
23
- }
24
- }
25
- }
26
- async function _diveHelper(directory, action, options = {}) {
27
- for await (const [file, stat] of _diveWorker(directory, options)) {
28
- await action(file, stat);
29
- }
30
- }
31
- async function _diveWorkerCallback(directory, action, options = {}) {
32
- let children;
33
- try {
34
- children = await fs.readdir(directory, { withFileTypes: true });
35
- } catch (err) {
36
- action(err);
37
- return;
38
- }
39
- if (children.length === 0 && options.directories) {
40
- action(null, directory, await fs.stat(directory));
41
- }
42
- for (const dirent of children) {
43
- if (!options.all && dirent.name.startsWith(".")) continue;
44
- const path = pathResolve(dirent.path ?? directory, dirent.name);
45
- if (options.ignore && matches(path, options.ignore)) continue;
46
- try {
47
- if (dirent.isDirectory()) {
48
- if (options.recursive) {
49
- await _diveWorkerCallback(path, action, options);
50
- } else if (options.directories) {
51
- action(null, path, await fs.stat(path));
52
- }
53
- } else if (options.files) {
54
- action(null, path, await fs.stat(path));
55
- }
56
- } catch (err) {
57
- action(err);
58
- }
59
- }
60
- }
61
- export function dive(directory, o1, o2, o3) {
62
- const options = (typeof o1 === "object" ? o1 : void 0) ?? {};
63
- const action = options === o1 ? o2 : o1;
64
- const complete = options === o1 ? o3 : o2;
65
- const opts = { ...DEFAULT_OPTS, ...options };
66
- if (!complete) {
67
- return _diveHelper(directory, action, opts);
68
- }
69
- void _diveWorkerCallback(directory, action, opts).finally(
70
- complete
71
- );
72
- }
73
- function* _diveSyncWorker(directory, options = {}) {
74
- const opts = { ...DEFAULT_OPTS, ...options };
75
- const children = fs.readdirSync(directory, { withFileTypes: true });
76
- if (children.length === 0 && opts.directories) yield directory;
77
- for (const dirent of children) {
78
- if (!opts.all && dirent.name.startsWith(".")) continue;
79
- const path = pathResolve(dirent.path ?? directory, dirent.name);
80
- if (opts.ignore && matches(path, opts.ignore)) continue;
81
- if (dirent.isDirectory()) {
82
- if (opts.recursive) yield* _diveSyncWorker(path, opts);
83
- else if (opts.directories) yield path;
84
- } else if (opts.files) {
85
- yield path;
86
- }
87
- }
88
- }
89
- export function diveSync(directory, options = {}) {
90
- return [..._diveSyncWorker(directory, options)];
91
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Test whether or not the given path exists by checking with the file system. Like
3
- * [`fs.exists`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback), but with a normal
4
- * callback signature (err, exists). Uses `fs.access` under the hood.
5
- *
6
- * @example
7
- * import * as fs from 'fs-extra'
8
- *
9
- * const file = '/tmp/this/path/does/not/exist/file.txt'
10
- *
11
- * // With a callback:
12
- * fs.pathExists(file, (err, exists) => {
13
- * console.log(err) // => null
14
- * console.log(exists) // => false
15
- * })
16
- *
17
- * // Promise usage:
18
- * fs.pathExists(file)
19
- * .then(exists => console.log(exists)) // => false
20
- *
21
- * // With async/await:
22
- * async function asyncAwait () {
23
- * const exists = await fs.pathExists(file)
24
- *
25
- * console.log(exists) // => false
26
- * }
27
- *
28
- * asyncAwait()
29
- */
30
- export declare function exists(path: string): Promise<boolean>;
31
- export declare function exists(path: string, callback: (err: NodeJS.ErrnoException | null, exists: boolean) => void): void;
@@ -1,10 +0,0 @@
1
- import { access } from "./index.js";
2
- export function exists(path, callback) {
3
- if (callback) {
4
- return access(path, (err) => callback(null, !err));
5
- }
6
- return access(path).then(
7
- () => true,
8
- () => false
9
- );
10
- }
@@ -1,34 +0,0 @@
1
- import type { ErrorCallback } from "../../types.js";
2
- /**
3
- * Iterate through every child of a folder, asynchronously. This function will not recurse into subdirectories.
4
- * @param path folder path to iterate through
5
- * @param options options to pass through to [[readdir]]
6
- * @param func iterate function, called for every child
7
- * @param callback function to call after the operation finishes
8
- */
9
- export declare function forEachChild(path: string, options: {
10
- encoding: BufferEncoding | null;
11
- } | BufferEncoding | null | undefined | Record<string, never>, func: (filename: string) => void | Promise<void>): Promise<void>;
12
- export declare function forEachChild(path: string, options: {
13
- encoding: "buffer";
14
- } | "buffer", func: (filename: Buffer) => void | Promise<void>): Promise<void>;
15
- export declare function forEachChild(path: string, func: (filename: string) => void | Promise<void>): Promise<void>;
16
- export declare function forEachChild(path: string, options: {
17
- encoding: BufferEncoding | null;
18
- } | BufferEncoding | null | undefined | Record<string, never>, func: (filename: string) => void, callback: ErrorCallback): void;
19
- export declare function forEachChild(path: string, options: {
20
- encoding: "buffer";
21
- } | "buffer", func: (filename: Buffer) => void, callback: ErrorCallback): void;
22
- export declare function forEachChild(path: string, func: (filename: string) => void, callback: ErrorCallback): void;
23
- /**
24
- * Iterate through every child of a folder, synchronously. This function will not recurse into subdirectories.
25
- * @param path folder path to iterate through
26
- * @param func iterate function, called for every child
27
- * @param options options to pass through to [[readdirSync]]
28
- */
29
- export declare function forEachChildSync(path: string, func: (filename: string) => void, options: {
30
- encoding: BufferEncoding | null;
31
- } | BufferEncoding | null | undefined | Record<string, never>): void;
32
- export declare function forEachChildSync(path: string, func: (filename: Buffer) => void, options?: {
33
- encoding: "buffer";
34
- } | "buffer"): void;
@@ -1,37 +0,0 @@
1
- import * as fs from "./index.js";
2
- async function _forEachChildHelper(path, options, func) {
3
- const children = await fs.readdir(path, options);
4
- for (const child of children) {
5
- const ret = func(child);
6
- if (ret instanceof Promise) {
7
- await ret;
8
- }
9
- }
10
- }
11
- export function forEachChild(path, o1, o2, o3) {
12
- const options = typeof o1 == "object" ? o1 : void 0;
13
- const func = !options ? o1 : o2;
14
- const callback = !options ? o2 : o3;
15
- if (!callback) {
16
- return _forEachChildHelper(path, options, func);
17
- }
18
- fs.readdir(path, options, (err, children) => {
19
- if (err) {
20
- callback(err);
21
- } else {
22
- for (const child of children) {
23
- func(child);
24
- }
25
- callback();
26
- }
27
- });
28
- }
29
- export function forEachChildSync(path, func, options) {
30
- const children = fs.readdirSync(
31
- path,
32
- options
33
- );
34
- for (const child of children) {
35
- func(child);
36
- }
37
- }