@bemoje/fs 1.1.1 → 1.1.3

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 (52) hide show
  1. package/README.md +20 -19
  2. package/lib/index.d.cts +113 -13
  3. package/lib/index.d.ts +113 -13
  4. package/package.json +23 -181
  5. package/lib/deleteOlderThan.cjs +0 -30
  6. package/lib/deleteOlderThan.d.cts +0 -8
  7. package/lib/deleteOlderThan.d.ts +0 -8
  8. package/lib/deleteOlderThan.js +0 -24
  9. package/lib/getFileAge.cjs +0 -18
  10. package/lib/getFileAge.d.cts +0 -7
  11. package/lib/getFileAge.d.ts +0 -7
  12. package/lib/getFileAge.js +0 -12
  13. package/lib/getFirstFileInDir.cjs +0 -26
  14. package/lib/getFirstFileInDir.d.cts +0 -6
  15. package/lib/getFirstFileInDir.d.ts +0 -6
  16. package/lib/getFirstFileInDir.js +0 -20
  17. package/lib/readFileFirstLine.cjs +0 -26
  18. package/lib/readFileFirstLine.d.cts +0 -6
  19. package/lib/readFileFirstLine.d.ts +0 -6
  20. package/lib/readFileFirstLine.js +0 -19
  21. package/lib/removeDataUrlSchemePrefix.cjs +0 -12
  22. package/lib/removeDataUrlSchemePrefix.d.cts +0 -8
  23. package/lib/removeDataUrlSchemePrefix.d.ts +0 -8
  24. package/lib/removeDataUrlSchemePrefix.js +0 -10
  25. package/lib/updateFile.cjs +0 -19
  26. package/lib/updateFile.d.cts +0 -7
  27. package/lib/updateFile.d.ts +0 -7
  28. package/lib/updateFile.js +0 -13
  29. package/lib/updateFileLines.cjs +0 -21
  30. package/lib/updateFileLines.d.cts +0 -8
  31. package/lib/updateFileLines.d.ts +0 -8
  32. package/lib/updateFileLines.js +0 -15
  33. package/lib/updateFileLinesSync.cjs +0 -21
  34. package/lib/updateFileLinesSync.d.cts +0 -6
  35. package/lib/updateFileLinesSync.d.ts +0 -6
  36. package/lib/updateFileLinesSync.js +0 -15
  37. package/lib/updateFileSync.cjs +0 -19
  38. package/lib/updateFileSync.d.cts +0 -6
  39. package/lib/updateFileSync.d.ts +0 -6
  40. package/lib/updateFileSync.js +0 -13
  41. package/lib/updateJsonFile.cjs +0 -23
  42. package/lib/updateJsonFile.d.cts +0 -8
  43. package/lib/updateJsonFile.d.ts +0 -8
  44. package/lib/updateJsonFile.js +0 -17
  45. package/lib/updateJsonFileSync.cjs +0 -23
  46. package/lib/updateJsonFileSync.d.cts +0 -6
  47. package/lib/updateJsonFileSync.d.ts +0 -6
  48. package/lib/updateJsonFileSync.js +0 -17
  49. package/lib/walkDirectory.cjs +0 -71
  50. package/lib/walkDirectory.d.cts +0 -48
  51. package/lib/walkDirectory.d.ts +0 -48
  52. package/lib/walkDirectory.js +0 -63
@@ -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 };
@@ -1,63 +0,0 @@
1
- import fs from 'fs-extra';
2
- import upath from 'upath';
3
- import walkdir from 'walkdir';
4
-
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- function walkDirectory(dirpath, options) {
8
- dirpath = upath.normalizeSafe(dirpath);
9
- if (!options.stats && !options.only) {
10
- return walkdir.sync(dirpath, {
11
- ...convertToWalkdirOptions(options),
12
- return_object: false
13
- }).map((fspath) => {
14
- return upath.normalizeSafe(fspath);
15
- });
16
- }
17
- let entries = Object.entries(walkdir.sync(dirpath, convertToWalkdirOptions(options)));
18
- if (options.only === "files") {
19
- entries = entries.filter(([_, stats]) => {
20
- return stats.isFile();
21
- });
22
- } else if (options.only === "directories") {
23
- entries = entries.filter(([_, stats]) => {
24
- return stats.isDirectory();
25
- });
26
- }
27
- entries = entries.map(([fspath, stats]) => {
28
- return [
29
- upath.normalizeSafe(fspath),
30
- stats
31
- ];
32
- });
33
- return options.stats ? entries : entries.map(([fspath]) => {
34
- return fspath;
35
- });
36
- }
37
- __name(walkDirectory, "walkDirectory");
38
- function convertToWalkdirOptions(options) {
39
- const result = {
40
- fs,
41
- sync: true,
42
- return_object: true
43
- };
44
- if (options.maxDepth !== void 0) {
45
- result.max_depth = options.maxDepth;
46
- }
47
- if (options.followSymlinks !== void 0) {
48
- result.follow_symlinks = options.followSymlinks;
49
- }
50
- if (options.ignoreInodes !== void 0) {
51
- result.track_inodes = !options.ignoreInodes;
52
- }
53
- if (options.filter) {
54
- const filter = options.filter;
55
- result.filter = (dirpath, files) => {
56
- return filter(upath.normalizeSafe(dirpath), upath.basename(dirpath)) ? files : [];
57
- };
58
- }
59
- return result;
60
- }
61
- __name(convertToWalkdirOptions, "convertToWalkdirOptions");
62
-
63
- export { walkDirectory };