@bemoje/fs 1.1.1 → 1.1.2

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 (51) hide show
  1. package/lib/index.d.cts +113 -13
  2. package/lib/index.d.ts +113 -13
  3. package/package.json +71 -119
  4. package/lib/deleteOlderThan.cjs +0 -30
  5. package/lib/deleteOlderThan.d.cts +0 -8
  6. package/lib/deleteOlderThan.d.ts +0 -8
  7. package/lib/deleteOlderThan.js +0 -24
  8. package/lib/getFileAge.cjs +0 -18
  9. package/lib/getFileAge.d.cts +0 -7
  10. package/lib/getFileAge.d.ts +0 -7
  11. package/lib/getFileAge.js +0 -12
  12. package/lib/getFirstFileInDir.cjs +0 -26
  13. package/lib/getFirstFileInDir.d.cts +0 -6
  14. package/lib/getFirstFileInDir.d.ts +0 -6
  15. package/lib/getFirstFileInDir.js +0 -20
  16. package/lib/readFileFirstLine.cjs +0 -26
  17. package/lib/readFileFirstLine.d.cts +0 -6
  18. package/lib/readFileFirstLine.d.ts +0 -6
  19. package/lib/readFileFirstLine.js +0 -19
  20. package/lib/removeDataUrlSchemePrefix.cjs +0 -12
  21. package/lib/removeDataUrlSchemePrefix.d.cts +0 -8
  22. package/lib/removeDataUrlSchemePrefix.d.ts +0 -8
  23. package/lib/removeDataUrlSchemePrefix.js +0 -10
  24. package/lib/updateFile.cjs +0 -19
  25. package/lib/updateFile.d.cts +0 -7
  26. package/lib/updateFile.d.ts +0 -7
  27. package/lib/updateFile.js +0 -13
  28. package/lib/updateFileLines.cjs +0 -21
  29. package/lib/updateFileLines.d.cts +0 -8
  30. package/lib/updateFileLines.d.ts +0 -8
  31. package/lib/updateFileLines.js +0 -15
  32. package/lib/updateFileLinesSync.cjs +0 -21
  33. package/lib/updateFileLinesSync.d.cts +0 -6
  34. package/lib/updateFileLinesSync.d.ts +0 -6
  35. package/lib/updateFileLinesSync.js +0 -15
  36. package/lib/updateFileSync.cjs +0 -19
  37. package/lib/updateFileSync.d.cts +0 -6
  38. package/lib/updateFileSync.d.ts +0 -6
  39. package/lib/updateFileSync.js +0 -13
  40. package/lib/updateJsonFile.cjs +0 -23
  41. package/lib/updateJsonFile.d.cts +0 -8
  42. package/lib/updateJsonFile.d.ts +0 -8
  43. package/lib/updateJsonFile.js +0 -17
  44. package/lib/updateJsonFileSync.cjs +0 -23
  45. package/lib/updateJsonFileSync.d.cts +0 -6
  46. package/lib/updateJsonFileSync.d.ts +0 -6
  47. package/lib/updateJsonFileSync.js +0 -17
  48. package/lib/walkDirectory.cjs +0 -71
  49. package/lib/walkDirectory.d.cts +0 -48
  50. package/lib/walkDirectory.d.ts +0 -48
  51. package/lib/walkDirectory.js +0 -63
package/lib/getFileAge.js DELETED
@@ -1,12 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- async function getFileAge(filepath) {
6
- const stats = await fs.stat(filepath);
7
- const time = stats.ctimeMs || stats.birthtimeMs || stats.mtimeMs;
8
- return Date.now() - time;
9
- }
10
- __name(getFileAge, "getFileAge");
11
-
12
- export { getFileAge };
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var fs__default = /*#__PURE__*/_interopDefault(fs);
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- async function getFirstFileInDir(dirpath) {
12
- const dirents = await fs__default.default.readdir(dirpath, {
13
- withFileTypes: true
14
- });
15
- const fileDirents = dirents.filter((file) => {
16
- return file.isFile();
17
- });
18
- const filenames = fileDirents.map((file) => {
19
- return file.name;
20
- });
21
- const firstFileName = filenames[0];
22
- return firstFileName;
23
- }
24
- __name(getFirstFileInDir, "getFirstFileInDir");
25
-
26
- exports.getFirstFileInDir = getFirstFileInDir;
@@ -1,6 +0,0 @@
1
- /**
2
- * Get the name of the first file (not directory) found in a directory.
3
- */
4
- declare function getFirstFileInDir(dirpath: string): Promise<string>;
5
-
6
- export { getFirstFileInDir };
@@ -1,6 +0,0 @@
1
- /**
2
- * Get the name of the first file (not directory) found in a directory.
3
- */
4
- declare function getFirstFileInDir(dirpath: string): Promise<string>;
5
-
6
- export { getFirstFileInDir };
@@ -1,20 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- async function getFirstFileInDir(dirpath) {
6
- const dirents = await fs.readdir(dirpath, {
7
- withFileTypes: true
8
- });
9
- const fileDirents = dirents.filter((file) => {
10
- return file.isFile();
11
- });
12
- const filenames = fileDirents.map((file) => {
13
- return file.name;
14
- });
15
- const firstFileName = filenames[0];
16
- return firstFileName;
17
- }
18
- __name(getFirstFileInDir, "getFirstFileInDir");
19
-
20
- export { getFirstFileInDir };
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
- var readline = require('readline');
5
-
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var fs__default = /*#__PURE__*/_interopDefault(fs);
9
- var readline__default = /*#__PURE__*/_interopDefault(readline);
10
-
11
- var __defProp = Object.defineProperty;
12
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
- async function readFileFirstLine(filepath) {
14
- const fileStream = fs__default.default.createReadStream(filepath, "utf8");
15
- const rl = readline__default.default.createInterface({
16
- input: fileStream,
17
- crlfDelay: Infinity
18
- });
19
- for await (const line of rl) {
20
- return line.trim();
21
- }
22
- return "";
23
- }
24
- __name(readFileFirstLine, "readFileFirstLine");
25
-
26
- exports.readFileFirstLine = readFileFirstLine;
@@ -1,6 +0,0 @@
1
- /**
2
- * Reads the first line of a file asynchronously.
3
- */
4
- declare function readFileFirstLine(filepath: string): Promise<string>;
5
-
6
- export { readFileFirstLine };
@@ -1,6 +0,0 @@
1
- /**
2
- * Reads the first line of a file asynchronously.
3
- */
4
- declare function readFileFirstLine(filepath: string): Promise<string>;
5
-
6
- export { readFileFirstLine };
@@ -1,19 +0,0 @@
1
- import fs from 'fs-extra';
2
- import readline from 'readline';
3
-
4
- var __defProp = Object.defineProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- async function readFileFirstLine(filepath) {
7
- const fileStream = fs.createReadStream(filepath, "utf8");
8
- const rl = readline.createInterface({
9
- input: fileStream,
10
- crlfDelay: Infinity
11
- });
12
- for await (const line of rl) {
13
- return line.trim();
14
- }
15
- return "";
16
- }
17
- __name(readFileFirstLine, "readFileFirstLine");
18
-
19
- export { readFileFirstLine };
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
-
6
- // src/removeDataUrlSchemePrefix.ts
7
- function removeDataUrlSchemePrefix(dataUrl) {
8
- return dataUrl.replace(/^data:.+;base64,/, "");
9
- }
10
- __name(removeDataUrlSchemePrefix, "removeDataUrlSchemePrefix");
11
-
12
- exports.removeDataUrlSchemePrefix = removeDataUrlSchemePrefix;
@@ -1,8 +0,0 @@
1
- /**
2
- * Removes the data URL scheme prefix from a given string.
3
- * @param dataUrl - The string to remove the prefix from.
4
- * @returns The string with the prefix removed.
5
- */
6
- declare function removeDataUrlSchemePrefix(dataUrl: string): string;
7
-
8
- export { removeDataUrlSchemePrefix };
@@ -1,8 +0,0 @@
1
- /**
2
- * Removes the data URL scheme prefix from a given string.
3
- * @param dataUrl - The string to remove the prefix from.
4
- * @returns The string with the prefix removed.
5
- */
6
- declare function removeDataUrlSchemePrefix(dataUrl: string): string;
7
-
8
- export { removeDataUrlSchemePrefix };
@@ -1,10 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // src/removeDataUrlSchemePrefix.ts
5
- function removeDataUrlSchemePrefix(dataUrl) {
6
- return dataUrl.replace(/^data:.+;base64,/, "");
7
- }
8
- __name(removeDataUrlSchemePrefix, "removeDataUrlSchemePrefix");
9
-
10
- export { removeDataUrlSchemePrefix };
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var fs__default = /*#__PURE__*/_interopDefault(fs);
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- async function updateFile(filepath, update) {
12
- await fs__default.default.ensureFile(filepath);
13
- const content = await fs__default.default.readFile(filepath, "utf8");
14
- const updated = await update(content);
15
- await fs__default.default.outputFile(filepath, updated);
16
- }
17
- __name(updateFile, "updateFile");
18
-
19
- exports.updateFile = updateFile;
@@ -1,7 +0,0 @@
1
- /**
2
- * Updates a file by reading its content, applying a transformation function, and writing back the result.
3
- * Creates the file and directories if they don't exist.
4
- */
5
- declare function updateFile(filepath: string, update: (fileContent: string) => string | Promise<string>): Promise<void>;
6
-
7
- export { updateFile };
@@ -1,7 +0,0 @@
1
- /**
2
- * Updates a file by reading its content, applying a transformation function, and writing back the result.
3
- * Creates the file and directories if they don't exist.
4
- */
5
- declare function updateFile(filepath: string, update: (fileContent: string) => string | Promise<string>): Promise<void>;
6
-
7
- export { updateFile };
package/lib/updateFile.js DELETED
@@ -1,13 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- async function updateFile(filepath, update) {
6
- await fs.ensureFile(filepath);
7
- const content = await fs.readFile(filepath, "utf8");
8
- const updated = await update(content);
9
- await fs.outputFile(filepath, updated);
10
- }
11
- __name(updateFile, "updateFile");
12
-
13
- export { updateFile };
@@ -1,21 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var fs__default = /*#__PURE__*/_interopDefault(fs);
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- async function updateFileLines(filepath, update) {
12
- await fs__default.default.ensureFile(filepath);
13
- const content = await fs__default.default.readFile(filepath, "utf8");
14
- const lines = content.split(/\r?\n/);
15
- const retval = await update(lines);
16
- const updated = Array.isArray(retval) ? retval.join("\n") : retval;
17
- await fs__default.default.outputFile(filepath, updated);
18
- }
19
- __name(updateFileLines, "updateFileLines");
20
-
21
- exports.updateFileLines = updateFileLines;
@@ -1,8 +0,0 @@
1
- /**
2
- * Updates a file by applying a transformation function to an array of lines.
3
- * The transformation can return either a string (the entire new content) or an array of lines.
4
- * Creates the file and directories if they don't exist.
5
- */
6
- declare function updateFileLines(filepath: string, update: (fileContentLines: string[]) => string | string[] | Promise<string | string[]>): Promise<void>;
7
-
8
- export { updateFileLines };
@@ -1,8 +0,0 @@
1
- /**
2
- * Updates a file by applying a transformation function to an array of lines.
3
- * The transformation can return either a string (the entire new content) or an array of lines.
4
- * Creates the file and directories if they don't exist.
5
- */
6
- declare function updateFileLines(filepath: string, update: (fileContentLines: string[]) => string | string[] | Promise<string | string[]>): Promise<void>;
7
-
8
- export { updateFileLines };
@@ -1,15 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- async function updateFileLines(filepath, update) {
6
- await fs.ensureFile(filepath);
7
- const content = await fs.readFile(filepath, "utf8");
8
- const lines = content.split(/\r?\n/);
9
- const retval = await update(lines);
10
- const updated = Array.isArray(retval) ? retval.join("\n") : retval;
11
- await fs.outputFile(filepath, updated);
12
- }
13
- __name(updateFileLines, "updateFileLines");
14
-
15
- export { updateFileLines };
@@ -1,21 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var fs__default = /*#__PURE__*/_interopDefault(fs);
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- function updateFileLinesSync(filepath, update) {
12
- fs__default.default.ensureFileSync(filepath);
13
- const content = fs__default.default.readFileSync(filepath, "utf8");
14
- const lines = content.split(/\r?\n/);
15
- const retval = update(lines);
16
- const updated = Array.isArray(retval) ? retval.join("\n") : retval;
17
- fs__default.default.outputFileSync(filepath, updated);
18
- }
19
- __name(updateFileLinesSync, "updateFileLinesSync");
20
-
21
- exports.updateFileLinesSync = updateFileLinesSync;
@@ -1,6 +0,0 @@
1
- /**
2
- * Synchronous version of `updateFileLines`.
3
- */
4
- declare function updateFileLinesSync(filepath: string, update: (fileContentLines: string[]) => string | string[]): void;
5
-
6
- export { updateFileLinesSync };
@@ -1,6 +0,0 @@
1
- /**
2
- * Synchronous version of `updateFileLines`.
3
- */
4
- declare function updateFileLinesSync(filepath: string, update: (fileContentLines: string[]) => string | string[]): void;
5
-
6
- export { updateFileLinesSync };
@@ -1,15 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- function updateFileLinesSync(filepath, update) {
6
- fs.ensureFileSync(filepath);
7
- const content = fs.readFileSync(filepath, "utf8");
8
- const lines = content.split(/\r?\n/);
9
- const retval = update(lines);
10
- const updated = Array.isArray(retval) ? retval.join("\n") : retval;
11
- fs.outputFileSync(filepath, updated);
12
- }
13
- __name(updateFileLinesSync, "updateFileLinesSync");
14
-
15
- export { updateFileLinesSync };
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var fs__default = /*#__PURE__*/_interopDefault(fs);
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- function updateFileSync(filepath, update) {
12
- fs__default.default.ensureFileSync(filepath);
13
- const content = fs__default.default.readFileSync(filepath, "utf8");
14
- const updated = update(content);
15
- fs__default.default.outputFileSync(filepath, updated);
16
- }
17
- __name(updateFileSync, "updateFileSync");
18
-
19
- exports.updateFileSync = updateFileSync;
@@ -1,6 +0,0 @@
1
- /**
2
- * Synchronous version of `updateFile`.
3
- */
4
- declare function updateFileSync(filepath: string, update: (fileContent: string) => string): void;
5
-
6
- export { updateFileSync };
@@ -1,6 +0,0 @@
1
- /**
2
- * Synchronous version of `updateFile`.
3
- */
4
- declare function updateFileSync(filepath: string, update: (fileContent: string) => string): void;
5
-
6
- export { updateFileSync };
@@ -1,13 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- function updateFileSync(filepath, update) {
6
- fs.ensureFileSync(filepath);
7
- const content = fs.readFileSync(filepath, "utf8");
8
- const updated = update(content);
9
- fs.outputFileSync(filepath, updated);
10
- }
11
- __name(updateFileSync, "updateFileSync");
12
-
13
- export { updateFileSync };
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var fs__default = /*#__PURE__*/_interopDefault(fs);
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- async function updateJsonFile(filepath, update, defaultValue = {}) {
12
- let content = defaultValue;
13
- try {
14
- content = await fs__default.default.readJson(filepath);
15
- } catch (_) {
16
- }
17
- const updated = await update(content);
18
- await fs__default.default.outputJson(filepath, updated);
19
- return updated;
20
- }
21
- __name(updateJsonFile, "updateJsonFile");
22
-
23
- exports.updateJsonFile = updateJsonFile;
@@ -1,8 +0,0 @@
1
- /**
2
- * Updates a JSON file by applying a transformation function to the parsed content.
3
- * If the file doesn't exist or can't be parsed, uses the default value.
4
- * Creates the file and directories if they don't exist.
5
- */
6
- declare function updateJsonFile<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R | Promise<R>, defaultValue?: T): Promise<R>;
7
-
8
- export { updateJsonFile };
@@ -1,8 +0,0 @@
1
- /**
2
- * Updates a JSON file by applying a transformation function to the parsed content.
3
- * If the file doesn't exist or can't be parsed, uses the default value.
4
- * Creates the file and directories if they don't exist.
5
- */
6
- declare function updateJsonFile<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R | Promise<R>, defaultValue?: T): Promise<R>;
7
-
8
- export { updateJsonFile };
@@ -1,17 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- async function updateJsonFile(filepath, update, defaultValue = {}) {
6
- let content = defaultValue;
7
- try {
8
- content = await fs.readJson(filepath);
9
- } catch (_) {
10
- }
11
- const updated = await update(content);
12
- await fs.outputJson(filepath, updated);
13
- return updated;
14
- }
15
- __name(updateJsonFile, "updateJsonFile");
16
-
17
- export { updateJsonFile };
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var fs__default = /*#__PURE__*/_interopDefault(fs);
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- function updateJsonFileSync(filepath, update, defaultValue = {}) {
12
- let content = defaultValue;
13
- try {
14
- content = fs__default.default.readJsonSync(filepath);
15
- } catch (_) {
16
- }
17
- const updated = update(content);
18
- fs__default.default.outputJsonSync(filepath, updated);
19
- return updated;
20
- }
21
- __name(updateJsonFileSync, "updateJsonFileSync");
22
-
23
- exports.updateJsonFileSync = updateJsonFileSync;
@@ -1,6 +0,0 @@
1
- /**
2
- * Synchronous version of `updateJsonFile`.
3
- */
4
- declare function updateJsonFileSync<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R, defaultValue?: T): R;
5
-
6
- export { updateJsonFileSync };
@@ -1,6 +0,0 @@
1
- /**
2
- * Synchronous version of `updateJsonFile`.
3
- */
4
- declare function updateJsonFileSync<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R, defaultValue?: T): R;
5
-
6
- export { updateJsonFileSync };
@@ -1,17 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- function updateJsonFileSync(filepath, update, defaultValue = {}) {
6
- let content = defaultValue;
7
- try {
8
- content = fs.readJsonSync(filepath);
9
- } catch (_) {
10
- }
11
- const updated = update(content);
12
- fs.outputJsonSync(filepath, updated);
13
- return updated;
14
- }
15
- __name(updateJsonFileSync, "updateJsonFileSync");
16
-
17
- export { updateJsonFileSync };
@@ -1,71 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
- var upath = require('upath');
5
- var walkdir = require('walkdir');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
-
9
- var fs__default = /*#__PURE__*/_interopDefault(fs);
10
- var upath__default = /*#__PURE__*/_interopDefault(upath);
11
- var walkdir__default = /*#__PURE__*/_interopDefault(walkdir);
12
-
13
- var __defProp = Object.defineProperty;
14
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
- function walkDirectory(dirpath, options) {
16
- dirpath = upath__default.default.normalizeSafe(dirpath);
17
- if (!options.stats && !options.only) {
18
- return walkdir__default.default.sync(dirpath, {
19
- ...convertToWalkdirOptions(options),
20
- return_object: false
21
- }).map((fspath) => {
22
- return upath__default.default.normalizeSafe(fspath);
23
- });
24
- }
25
- let entries = Object.entries(walkdir__default.default.sync(dirpath, convertToWalkdirOptions(options)));
26
- if (options.only === "files") {
27
- entries = entries.filter(([_, stats]) => {
28
- return stats.isFile();
29
- });
30
- } else if (options.only === "directories") {
31
- entries = entries.filter(([_, stats]) => {
32
- return stats.isDirectory();
33
- });
34
- }
35
- entries = entries.map(([fspath, stats]) => {
36
- return [
37
- upath__default.default.normalizeSafe(fspath),
38
- stats
39
- ];
40
- });
41
- return options.stats ? entries : entries.map(([fspath]) => {
42
- return fspath;
43
- });
44
- }
45
- __name(walkDirectory, "walkDirectory");
46
- function convertToWalkdirOptions(options) {
47
- const result = {
48
- fs: fs__default.default,
49
- sync: true,
50
- return_object: true
51
- };
52
- if (options.maxDepth !== void 0) {
53
- result.max_depth = options.maxDepth;
54
- }
55
- if (options.followSymlinks !== void 0) {
56
- result.follow_symlinks = options.followSymlinks;
57
- }
58
- if (options.ignoreInodes !== void 0) {
59
- result.track_inodes = !options.ignoreInodes;
60
- }
61
- if (options.filter) {
62
- const filter = options.filter;
63
- result.filter = (dirpath, files) => {
64
- return filter(upath__default.default.normalizeSafe(dirpath), upath__default.default.basename(dirpath)) ? files : [];
65
- };
66
- }
67
- return result;
68
- }
69
- __name(convertToWalkdirOptions, "convertToWalkdirOptions");
70
-
71
- exports.walkDirectory = walkDirectory;
@@ -1,48 +0,0 @@
1
- import { Stats } from 'fs-extra';
2
-
3
- /**
4
- * Walk a directory recursively and return an array of paths.
5
- */
6
- declare function walkDirectory(dirpath: string, options: WalkDirectoryOptionsWithoutStats): string[];
7
- /**
8
- * Walk a directory recursively and return an array of [path: string, stats: Stats] tuples.
9
- */
10
- declare function walkDirectory(dirpath: string, options: WalkDirectoryOptionsWithStats): [path: string, stats: Stats][];
11
- /**
12
- * Options for @see walkDirectory
13
- */
14
- interface WalkDirectoryOptions {
15
- /**
16
- * Return stats for each path.
17
- */
18
- stats?: boolean;
19
- /**
20
- * Only return either files or directories.
21
- */
22
- only?: 'files' | 'directories';
23
- /**
24
- * Recursion depth limit.
25
- */
26
- maxDepth?: number;
27
- /**
28
- * Determine whether to walk a given directory.
29
- */
30
- filter?: (dirpath: string, basename: string) => boolean;
31
- /**
32
- * Follow symbolic links.
33
- */
34
- followSymlinks?: boolean;
35
- /**
36
- * On filesystems where inodes are not unique (eg. windows), some files may not be walked due to inode collision.
37
- * Turning off this behavior may be required but at the same time may lead to hitting max_depth via link loop.
38
- */
39
- ignoreInodes?: boolean;
40
- }
41
- interface WalkDirectoryOptionsWithoutStats extends WalkDirectoryOptions {
42
- stats?: false;
43
- }
44
- interface WalkDirectoryOptionsWithStats extends WalkDirectoryOptions {
45
- stats: true;
46
- }
47
-
48
- export { type WalkDirectoryOptions, type WalkDirectoryOptionsWithStats, type WalkDirectoryOptionsWithoutStats, walkDirectory };