@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.
- package/README.md +20 -19
- package/lib/index.d.cts +113 -13
- package/lib/index.d.ts +113 -13
- package/package.json +23 -181
- package/lib/deleteOlderThan.cjs +0 -30
- package/lib/deleteOlderThan.d.cts +0 -8
- package/lib/deleteOlderThan.d.ts +0 -8
- package/lib/deleteOlderThan.js +0 -24
- package/lib/getFileAge.cjs +0 -18
- package/lib/getFileAge.d.cts +0 -7
- package/lib/getFileAge.d.ts +0 -7
- package/lib/getFileAge.js +0 -12
- package/lib/getFirstFileInDir.cjs +0 -26
- package/lib/getFirstFileInDir.d.cts +0 -6
- package/lib/getFirstFileInDir.d.ts +0 -6
- package/lib/getFirstFileInDir.js +0 -20
- package/lib/readFileFirstLine.cjs +0 -26
- package/lib/readFileFirstLine.d.cts +0 -6
- package/lib/readFileFirstLine.d.ts +0 -6
- package/lib/readFileFirstLine.js +0 -19
- package/lib/removeDataUrlSchemePrefix.cjs +0 -12
- package/lib/removeDataUrlSchemePrefix.d.cts +0 -8
- package/lib/removeDataUrlSchemePrefix.d.ts +0 -8
- package/lib/removeDataUrlSchemePrefix.js +0 -10
- package/lib/updateFile.cjs +0 -19
- package/lib/updateFile.d.cts +0 -7
- package/lib/updateFile.d.ts +0 -7
- package/lib/updateFile.js +0 -13
- package/lib/updateFileLines.cjs +0 -21
- package/lib/updateFileLines.d.cts +0 -8
- package/lib/updateFileLines.d.ts +0 -8
- package/lib/updateFileLines.js +0 -15
- package/lib/updateFileLinesSync.cjs +0 -21
- package/lib/updateFileLinesSync.d.cts +0 -6
- package/lib/updateFileLinesSync.d.ts +0 -6
- package/lib/updateFileLinesSync.js +0 -15
- package/lib/updateFileSync.cjs +0 -19
- package/lib/updateFileSync.d.cts +0 -6
- package/lib/updateFileSync.d.ts +0 -6
- package/lib/updateFileSync.js +0 -13
- package/lib/updateJsonFile.cjs +0 -23
- package/lib/updateJsonFile.d.cts +0 -8
- package/lib/updateJsonFile.d.ts +0 -8
- package/lib/updateJsonFile.js +0 -17
- package/lib/updateJsonFileSync.cjs +0 -23
- package/lib/updateJsonFileSync.d.cts +0 -6
- package/lib/updateJsonFileSync.d.ts +0 -6
- package/lib/updateJsonFileSync.js +0 -17
- package/lib/walkDirectory.cjs +0 -71
- package/lib/walkDirectory.d.cts +0 -48
- package/lib/walkDirectory.d.ts +0 -48
- package/lib/walkDirectory.js +0 -63
package/README.md
CHANGED
|
@@ -2,8 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
File system utilities for reading, updating, and managing files and directories.
|
|
4
4
|
|
|
5
|
-
[](https://www.typescriptlang.org/)
|
|
6
|
-
|
|
5
|
+
[](https://www.typescriptlang.org/) [](https://nodejs.org/api/esm.html)
|
|
6
|
+
|
|
7
|
+
## Exports
|
|
8
|
+
|
|
9
|
+
<!-- EXPORTS_START -->
|
|
10
|
+
|
|
11
|
+
- **deleteOlderThan**: Delete files older than a given timestamp
|
|
12
|
+
- **getFileAge**: Retrieves the age of a file in milliseconds.
|
|
13
|
+
- **getFirstFileInDir** found in a directory.
|
|
14
|
+
- **readFileFirstLine**: Reads the first line of a file asynchronously.
|
|
15
|
+
- **removeDataUrlSchemePrefix**: Removes the data URL scheme prefix from a given string.
|
|
16
|
+
- **updateFile**: Updates a file by reading its content, applying a transformation function, and writing back the result. Creates the file and directories if they don't exist.
|
|
17
|
+
- **updateFileLines** or an array of lines. Creates the file and directories if they don't exist.
|
|
18
|
+
- **updateFileLinesSync**: Synchronous version of `updateFileLines`.
|
|
19
|
+
- **updateFileSync**: Synchronous version of `updateFile`.
|
|
20
|
+
- **updateJsonFile**: Updates a JSON file by applying a transformation function to the parsed content. If the file doesn't exist or can't be parsed, uses the default value. Creates the file and directories if they don't exist.
|
|
21
|
+
- **updateJsonFileSync**: Synchronous version of `updateJsonFile`.
|
|
22
|
+
- **walkDirectory**: Walk a directory recursively and return an array of paths.
|
|
23
|
+
|
|
24
|
+
<!-- EXPORTS_END -->
|
|
7
25
|
|
|
8
26
|
## Installation
|
|
9
27
|
|
|
@@ -111,20 +129,3 @@ import { removeDataUrlSchemePrefix } from '@bemoje/fs'
|
|
|
111
129
|
removeDataUrlSchemePrefix('data:image/png;base64,iVBOR...')
|
|
112
130
|
// 'iVBOR...'
|
|
113
131
|
```
|
|
114
|
-
|
|
115
|
-
## API Reference
|
|
116
|
-
|
|
117
|
-
| Export | Description |
|
|
118
|
-
| --------------------------- | ----------------------------------------------------- |
|
|
119
|
-
| `walkDirectory` | Recursively walk a directory with filtering and stats |
|
|
120
|
-
| `updateFile` | Async read-transform-write a file |
|
|
121
|
-
| `updateFileSync` | Sync read-transform-write a file |
|
|
122
|
-
| `updateFileLines` | Async read-transform-write a file by lines |
|
|
123
|
-
| `updateFileLinesSync` | Sync read-transform-write a file by lines |
|
|
124
|
-
| `updateJsonFile` | Async read-transform-write a JSON file |
|
|
125
|
-
| `updateJsonFileSync` | Sync read-transform-write a JSON file |
|
|
126
|
-
| `deleteOlderThan` | Delete files older than a given age |
|
|
127
|
-
| `getFileAge` | Get file age in milliseconds |
|
|
128
|
-
| `getFirstFileInDir` | Get the first file name in a directory |
|
|
129
|
-
| `readFileFirstLine` | Read only the first line of a file |
|
|
130
|
-
| `removeDataUrlSchemePrefix` | Strip data URL scheme prefix from a string |
|
package/lib/index.d.cts
CHANGED
|
@@ -1,13 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { Stats } from 'fs-extra';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Delete files older than a given timestamp
|
|
5
|
+
* @param dp The dirpath to a folder in which to delete files from
|
|
6
|
+
* @param ageThreshold The age in milliseconds to compare against
|
|
7
|
+
*/
|
|
8
|
+
declare function deleteOlderThan(dp: string, ageThreshold: number): Promise<void>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the age of a file in milliseconds.
|
|
12
|
+
* @param filepath - The path to the file.
|
|
13
|
+
*/
|
|
14
|
+
declare function getFileAge(filepath: string): Promise<number>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get the name of the first file (not directory) found in a directory.
|
|
18
|
+
*/
|
|
19
|
+
declare function getFirstFileInDir(dirpath: string): Promise<string>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reads the first line of a file asynchronously.
|
|
23
|
+
*/
|
|
24
|
+
declare function readFileFirstLine(filepath: string): Promise<string>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Removes the data URL scheme prefix from a given string.
|
|
28
|
+
* @param dataUrl - The string to remove the prefix from.
|
|
29
|
+
* @returns The string with the prefix removed.
|
|
30
|
+
*/
|
|
31
|
+
declare function removeDataUrlSchemePrefix(dataUrl: string): string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Updates a file by reading its content, applying a transformation function, and writing back the result.
|
|
35
|
+
* Creates the file and directories if they don't exist.
|
|
36
|
+
*/
|
|
37
|
+
declare function updateFile(filepath: string, update: (fileContent: string) => string | Promise<string>): Promise<void>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Updates a file by applying a transformation function to an array of lines.
|
|
41
|
+
* The transformation can return either a string (the entire new content) or an array of lines.
|
|
42
|
+
* Creates the file and directories if they don't exist.
|
|
43
|
+
*/
|
|
44
|
+
declare function updateFileLines(filepath: string, update: (fileContentLines: string[]) => string | string[] | Promise<string | string[]>): Promise<void>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Synchronous version of `updateFileLines`.
|
|
48
|
+
*/
|
|
49
|
+
declare function updateFileLinesSync(filepath: string, update: (fileContentLines: string[]) => string | string[]): void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Synchronous version of `updateFile`.
|
|
53
|
+
*/
|
|
54
|
+
declare function updateFileSync(filepath: string, update: (fileContent: string) => string): void;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Updates a JSON file by applying a transformation function to the parsed content.
|
|
58
|
+
* If the file doesn't exist or can't be parsed, uses the default value.
|
|
59
|
+
* Creates the file and directories if they don't exist.
|
|
60
|
+
*/
|
|
61
|
+
declare function updateJsonFile<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R | Promise<R>, defaultValue?: T): Promise<R>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Synchronous version of `updateJsonFile`.
|
|
65
|
+
*/
|
|
66
|
+
declare function updateJsonFileSync<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R, defaultValue?: T): R;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Walk a directory recursively and return an array of paths.
|
|
70
|
+
*/
|
|
71
|
+
declare function walkDirectory(dirpath: string, options: WalkDirectoryOptionsWithoutStats): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Walk a directory recursively and return an array of [path: string, stats: Stats] tuples.
|
|
74
|
+
*/
|
|
75
|
+
declare function walkDirectory(dirpath: string, options: WalkDirectoryOptionsWithStats): [path: string, stats: Stats][];
|
|
76
|
+
/**
|
|
77
|
+
* Options for @see walkDirectory
|
|
78
|
+
*/
|
|
79
|
+
interface WalkDirectoryOptions {
|
|
80
|
+
/**
|
|
81
|
+
* Return stats for each path.
|
|
82
|
+
*/
|
|
83
|
+
stats?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Only return either files or directories.
|
|
86
|
+
*/
|
|
87
|
+
only?: 'files' | 'directories';
|
|
88
|
+
/**
|
|
89
|
+
* Recursion depth limit.
|
|
90
|
+
*/
|
|
91
|
+
maxDepth?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Determine whether to walk a given directory.
|
|
94
|
+
*/
|
|
95
|
+
filter?: (dirpath: string, basename: string) => boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Follow symbolic links.
|
|
98
|
+
*/
|
|
99
|
+
followSymlinks?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* On filesystems where inodes are not unique (eg. windows), some files may not be walked due to inode collision.
|
|
102
|
+
* Turning off this behavior may be required but at the same time may lead to hitting max_depth via link loop.
|
|
103
|
+
*/
|
|
104
|
+
ignoreInodes?: boolean;
|
|
105
|
+
}
|
|
106
|
+
interface WalkDirectoryOptionsWithoutStats extends WalkDirectoryOptions {
|
|
107
|
+
stats?: false;
|
|
108
|
+
}
|
|
109
|
+
interface WalkDirectoryOptionsWithStats extends WalkDirectoryOptions {
|
|
110
|
+
stats: true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { type WalkDirectoryOptions, type WalkDirectoryOptionsWithStats, type WalkDirectoryOptionsWithoutStats, deleteOlderThan, getFileAge, getFirstFileInDir, readFileFirstLine, removeDataUrlSchemePrefix, updateFile, updateFileLines, updateFileLinesSync, updateFileSync, updateJsonFile, updateJsonFileSync, walkDirectory };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,13 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { Stats } from 'fs-extra';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Delete files older than a given timestamp
|
|
5
|
+
* @param dp The dirpath to a folder in which to delete files from
|
|
6
|
+
* @param ageThreshold The age in milliseconds to compare against
|
|
7
|
+
*/
|
|
8
|
+
declare function deleteOlderThan(dp: string, ageThreshold: number): Promise<void>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the age of a file in milliseconds.
|
|
12
|
+
* @param filepath - The path to the file.
|
|
13
|
+
*/
|
|
14
|
+
declare function getFileAge(filepath: string): Promise<number>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get the name of the first file (not directory) found in a directory.
|
|
18
|
+
*/
|
|
19
|
+
declare function getFirstFileInDir(dirpath: string): Promise<string>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reads the first line of a file asynchronously.
|
|
23
|
+
*/
|
|
24
|
+
declare function readFileFirstLine(filepath: string): Promise<string>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Removes the data URL scheme prefix from a given string.
|
|
28
|
+
* @param dataUrl - The string to remove the prefix from.
|
|
29
|
+
* @returns The string with the prefix removed.
|
|
30
|
+
*/
|
|
31
|
+
declare function removeDataUrlSchemePrefix(dataUrl: string): string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Updates a file by reading its content, applying a transformation function, and writing back the result.
|
|
35
|
+
* Creates the file and directories if they don't exist.
|
|
36
|
+
*/
|
|
37
|
+
declare function updateFile(filepath: string, update: (fileContent: string) => string | Promise<string>): Promise<void>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Updates a file by applying a transformation function to an array of lines.
|
|
41
|
+
* The transformation can return either a string (the entire new content) or an array of lines.
|
|
42
|
+
* Creates the file and directories if they don't exist.
|
|
43
|
+
*/
|
|
44
|
+
declare function updateFileLines(filepath: string, update: (fileContentLines: string[]) => string | string[] | Promise<string | string[]>): Promise<void>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Synchronous version of `updateFileLines`.
|
|
48
|
+
*/
|
|
49
|
+
declare function updateFileLinesSync(filepath: string, update: (fileContentLines: string[]) => string | string[]): void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Synchronous version of `updateFile`.
|
|
53
|
+
*/
|
|
54
|
+
declare function updateFileSync(filepath: string, update: (fileContent: string) => string): void;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Updates a JSON file by applying a transformation function to the parsed content.
|
|
58
|
+
* If the file doesn't exist or can't be parsed, uses the default value.
|
|
59
|
+
* Creates the file and directories if they don't exist.
|
|
60
|
+
*/
|
|
61
|
+
declare function updateJsonFile<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R | Promise<R>, defaultValue?: T): Promise<R>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Synchronous version of `updateJsonFile`.
|
|
65
|
+
*/
|
|
66
|
+
declare function updateJsonFileSync<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R, defaultValue?: T): R;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Walk a directory recursively and return an array of paths.
|
|
70
|
+
*/
|
|
71
|
+
declare function walkDirectory(dirpath: string, options: WalkDirectoryOptionsWithoutStats): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Walk a directory recursively and return an array of [path: string, stats: Stats] tuples.
|
|
74
|
+
*/
|
|
75
|
+
declare function walkDirectory(dirpath: string, options: WalkDirectoryOptionsWithStats): [path: string, stats: Stats][];
|
|
76
|
+
/**
|
|
77
|
+
* Options for @see walkDirectory
|
|
78
|
+
*/
|
|
79
|
+
interface WalkDirectoryOptions {
|
|
80
|
+
/**
|
|
81
|
+
* Return stats for each path.
|
|
82
|
+
*/
|
|
83
|
+
stats?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Only return either files or directories.
|
|
86
|
+
*/
|
|
87
|
+
only?: 'files' | 'directories';
|
|
88
|
+
/**
|
|
89
|
+
* Recursion depth limit.
|
|
90
|
+
*/
|
|
91
|
+
maxDepth?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Determine whether to walk a given directory.
|
|
94
|
+
*/
|
|
95
|
+
filter?: (dirpath: string, basename: string) => boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Follow symbolic links.
|
|
98
|
+
*/
|
|
99
|
+
followSymlinks?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* On filesystems where inodes are not unique (eg. windows), some files may not be walked due to inode collision.
|
|
102
|
+
* Turning off this behavior may be required but at the same time may lead to hitting max_depth via link loop.
|
|
103
|
+
*/
|
|
104
|
+
ignoreInodes?: boolean;
|
|
105
|
+
}
|
|
106
|
+
interface WalkDirectoryOptionsWithoutStats extends WalkDirectoryOptions {
|
|
107
|
+
stats?: false;
|
|
108
|
+
}
|
|
109
|
+
interface WalkDirectoryOptionsWithStats extends WalkDirectoryOptions {
|
|
110
|
+
stats: true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { type WalkDirectoryOptions, type WalkDirectoryOptionsWithStats, type WalkDirectoryOptionsWithoutStats, deleteOlderThan, getFileAge, getFirstFileInDir, readFileFirstLine, removeDataUrlSchemePrefix, updateFile, updateFileLines, updateFileLinesSync, updateFileSync, updateJsonFile, updateJsonFileSync, walkDirectory };
|
package/package.json
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/fs",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "File system utilities for reading, updating, and managing files and directories.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"fs-extra": "^11.3.4",
|
|
12
|
+
"upath": "^2.0.1",
|
|
13
|
+
"walkdir": "^0.4.1",
|
|
14
|
+
"@types/fs-extra": "^11.0.4"
|
|
15
|
+
},
|
|
5
16
|
"keywords": [
|
|
6
17
|
"fs",
|
|
7
18
|
"file-system",
|
|
@@ -13,20 +24,15 @@
|
|
|
13
24
|
"utilities",
|
|
14
25
|
"typescript"
|
|
15
26
|
],
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"fs-extra": "^11.3.4",
|
|
18
|
-
"upath": "^2.0.1",
|
|
19
|
-
"walkdir": "^0.4.1",
|
|
20
|
-
"@types/fs-extra": "^11.0.4"
|
|
21
|
-
},
|
|
22
|
-
"type": "module",
|
|
23
|
-
"sideEffects": false,
|
|
24
|
-
"publishConfig": {
|
|
25
|
-
"access": "public"
|
|
26
|
-
},
|
|
27
27
|
"main": "./lib/index.cjs",
|
|
28
28
|
"module": "./lib/index.js",
|
|
29
29
|
"types": "./lib/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"./lib/index.js",
|
|
32
|
+
"./lib/index.d.ts",
|
|
33
|
+
"./lib/index.cjs",
|
|
34
|
+
"./lib/index.d.cts"
|
|
35
|
+
],
|
|
30
36
|
"exports": {
|
|
31
37
|
".": {
|
|
32
38
|
"import": {
|
|
@@ -38,181 +44,17 @@
|
|
|
38
44
|
"default": "./lib/index.cjs"
|
|
39
45
|
}
|
|
40
46
|
},
|
|
41
|
-
"
|
|
42
|
-
"import": {
|
|
43
|
-
"types": "./lib/deleteOlderThan.d.ts",
|
|
44
|
-
"default": "./lib/deleteOlderThan.js"
|
|
45
|
-
},
|
|
46
|
-
"require": {
|
|
47
|
-
"types": "./lib/deleteOlderThan.d.cts",
|
|
48
|
-
"default": "./lib/deleteOlderThan.cjs"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"./getFileAge": {
|
|
47
|
+
"./*": {
|
|
52
48
|
"import": {
|
|
53
|
-
"types": "./lib/
|
|
54
|
-
"default": "./lib/
|
|
55
|
-
},
|
|
56
|
-
"require": {
|
|
57
|
-
"types": "./lib/getFileAge.d.cts",
|
|
58
|
-
"default": "./lib/getFileAge.cjs"
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"./getFirstFileInDir": {
|
|
62
|
-
"import": {
|
|
63
|
-
"types": "./lib/getFirstFileInDir.d.ts",
|
|
64
|
-
"default": "./lib/getFirstFileInDir.js"
|
|
65
|
-
},
|
|
66
|
-
"require": {
|
|
67
|
-
"types": "./lib/getFirstFileInDir.d.cts",
|
|
68
|
-
"default": "./lib/getFirstFileInDir.cjs"
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
"./readFileFirstLine": {
|
|
72
|
-
"import": {
|
|
73
|
-
"types": "./lib/readFileFirstLine.d.ts",
|
|
74
|
-
"default": "./lib/readFileFirstLine.js"
|
|
75
|
-
},
|
|
76
|
-
"require": {
|
|
77
|
-
"types": "./lib/readFileFirstLine.d.cts",
|
|
78
|
-
"default": "./lib/readFileFirstLine.cjs"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
"./removeDataUrlSchemePrefix": {
|
|
82
|
-
"import": {
|
|
83
|
-
"types": "./lib/removeDataUrlSchemePrefix.d.ts",
|
|
84
|
-
"default": "./lib/removeDataUrlSchemePrefix.js"
|
|
85
|
-
},
|
|
86
|
-
"require": {
|
|
87
|
-
"types": "./lib/removeDataUrlSchemePrefix.d.cts",
|
|
88
|
-
"default": "./lib/removeDataUrlSchemePrefix.cjs"
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
"./updateFile": {
|
|
92
|
-
"import": {
|
|
93
|
-
"types": "./lib/updateFile.d.ts",
|
|
94
|
-
"default": "./lib/updateFile.js"
|
|
95
|
-
},
|
|
96
|
-
"require": {
|
|
97
|
-
"types": "./lib/updateFile.d.cts",
|
|
98
|
-
"default": "./lib/updateFile.cjs"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
"./updateFileLines": {
|
|
102
|
-
"import": {
|
|
103
|
-
"types": "./lib/updateFileLines.d.ts",
|
|
104
|
-
"default": "./lib/updateFileLines.js"
|
|
105
|
-
},
|
|
106
|
-
"require": {
|
|
107
|
-
"types": "./lib/updateFileLines.d.cts",
|
|
108
|
-
"default": "./lib/updateFileLines.cjs"
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
"./updateFileLinesSync": {
|
|
112
|
-
"import": {
|
|
113
|
-
"types": "./lib/updateFileLinesSync.d.ts",
|
|
114
|
-
"default": "./lib/updateFileLinesSync.js"
|
|
115
|
-
},
|
|
116
|
-
"require": {
|
|
117
|
-
"types": "./lib/updateFileLinesSync.d.cts",
|
|
118
|
-
"default": "./lib/updateFileLinesSync.cjs"
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
"./updateFileSync": {
|
|
122
|
-
"import": {
|
|
123
|
-
"types": "./lib/updateFileSync.d.ts",
|
|
124
|
-
"default": "./lib/updateFileSync.js"
|
|
125
|
-
},
|
|
126
|
-
"require": {
|
|
127
|
-
"types": "./lib/updateFileSync.d.cts",
|
|
128
|
-
"default": "./lib/updateFileSync.cjs"
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
"./updateJsonFile": {
|
|
132
|
-
"import": {
|
|
133
|
-
"types": "./lib/updateJsonFile.d.ts",
|
|
134
|
-
"default": "./lib/updateJsonFile.js"
|
|
135
|
-
},
|
|
136
|
-
"require": {
|
|
137
|
-
"types": "./lib/updateJsonFile.d.cts",
|
|
138
|
-
"default": "./lib/updateJsonFile.cjs"
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
"./updateJsonFileSync": {
|
|
142
|
-
"import": {
|
|
143
|
-
"types": "./lib/updateJsonFileSync.d.ts",
|
|
144
|
-
"default": "./lib/updateJsonFileSync.js"
|
|
145
|
-
},
|
|
146
|
-
"require": {
|
|
147
|
-
"types": "./lib/updateJsonFileSync.d.cts",
|
|
148
|
-
"default": "./lib/updateJsonFileSync.cjs"
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
"./walkDirectory": {
|
|
152
|
-
"import": {
|
|
153
|
-
"types": "./lib/walkDirectory.d.ts",
|
|
154
|
-
"default": "./lib/walkDirectory.js"
|
|
49
|
+
"types": "./lib/index.d.ts",
|
|
50
|
+
"default": "./lib/index.js"
|
|
155
51
|
},
|
|
156
52
|
"require": {
|
|
157
|
-
"types": "./lib/
|
|
158
|
-
"default": "./lib/
|
|
53
|
+
"types": "./lib/index.d.cts",
|
|
54
|
+
"default": "./lib/index.cjs"
|
|
159
55
|
}
|
|
160
56
|
}
|
|
161
57
|
},
|
|
162
|
-
"files": [
|
|
163
|
-
"./lib/index.js",
|
|
164
|
-
"./lib/index.d.ts",
|
|
165
|
-
"./lib/index.cjs",
|
|
166
|
-
"./lib/index.d.cts",
|
|
167
|
-
"./lib/deleteOlderThan.js",
|
|
168
|
-
"./lib/deleteOlderThan.d.ts",
|
|
169
|
-
"./lib/deleteOlderThan.cjs",
|
|
170
|
-
"./lib/deleteOlderThan.d.cts",
|
|
171
|
-
"./lib/getFileAge.js",
|
|
172
|
-
"./lib/getFileAge.d.ts",
|
|
173
|
-
"./lib/getFileAge.cjs",
|
|
174
|
-
"./lib/getFileAge.d.cts",
|
|
175
|
-
"./lib/getFirstFileInDir.js",
|
|
176
|
-
"./lib/getFirstFileInDir.d.ts",
|
|
177
|
-
"./lib/getFirstFileInDir.cjs",
|
|
178
|
-
"./lib/getFirstFileInDir.d.cts",
|
|
179
|
-
"./lib/readFileFirstLine.js",
|
|
180
|
-
"./lib/readFileFirstLine.d.ts",
|
|
181
|
-
"./lib/readFileFirstLine.cjs",
|
|
182
|
-
"./lib/readFileFirstLine.d.cts",
|
|
183
|
-
"./lib/removeDataUrlSchemePrefix.js",
|
|
184
|
-
"./lib/removeDataUrlSchemePrefix.d.ts",
|
|
185
|
-
"./lib/removeDataUrlSchemePrefix.cjs",
|
|
186
|
-
"./lib/removeDataUrlSchemePrefix.d.cts",
|
|
187
|
-
"./lib/updateFile.js",
|
|
188
|
-
"./lib/updateFile.d.ts",
|
|
189
|
-
"./lib/updateFile.cjs",
|
|
190
|
-
"./lib/updateFile.d.cts",
|
|
191
|
-
"./lib/updateFileLines.js",
|
|
192
|
-
"./lib/updateFileLines.d.ts",
|
|
193
|
-
"./lib/updateFileLines.cjs",
|
|
194
|
-
"./lib/updateFileLines.d.cts",
|
|
195
|
-
"./lib/updateFileLinesSync.js",
|
|
196
|
-
"./lib/updateFileLinesSync.d.ts",
|
|
197
|
-
"./lib/updateFileLinesSync.cjs",
|
|
198
|
-
"./lib/updateFileLinesSync.d.cts",
|
|
199
|
-
"./lib/updateFileSync.js",
|
|
200
|
-
"./lib/updateFileSync.d.ts",
|
|
201
|
-
"./lib/updateFileSync.cjs",
|
|
202
|
-
"./lib/updateFileSync.d.cts",
|
|
203
|
-
"./lib/updateJsonFile.js",
|
|
204
|
-
"./lib/updateJsonFile.d.ts",
|
|
205
|
-
"./lib/updateJsonFile.cjs",
|
|
206
|
-
"./lib/updateJsonFile.d.cts",
|
|
207
|
-
"./lib/updateJsonFileSync.js",
|
|
208
|
-
"./lib/updateJsonFileSync.d.ts",
|
|
209
|
-
"./lib/updateJsonFileSync.cjs",
|
|
210
|
-
"./lib/updateJsonFileSync.d.cts",
|
|
211
|
-
"./lib/walkDirectory.js",
|
|
212
|
-
"./lib/walkDirectory.d.ts",
|
|
213
|
-
"./lib/walkDirectory.cjs",
|
|
214
|
-
"./lib/walkDirectory.d.cts"
|
|
215
|
-
],
|
|
216
58
|
"repository": {
|
|
217
59
|
"type": "git",
|
|
218
60
|
"url": "git+https://github.com/bemoje/mono.git",
|
package/lib/deleteOlderThan.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs2 = require('fs-extra');
|
|
4
|
-
|
|
5
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
-
|
|
7
|
-
var fs2__default = /*#__PURE__*/_interopDefault(fs2);
|
|
8
|
-
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
-
async function getFileAge(filepath) {
|
|
12
|
-
const stats = await fs2__default.default.stat(filepath);
|
|
13
|
-
const time = stats.ctimeMs || stats.birthtimeMs || stats.mtimeMs;
|
|
14
|
-
return Date.now() - time;
|
|
15
|
-
}
|
|
16
|
-
__name(getFileAge, "getFileAge");
|
|
17
|
-
|
|
18
|
-
// src/deleteOlderThan.ts
|
|
19
|
-
async function deleteOlderThan(dp, ageThreshold) {
|
|
20
|
-
const files = await fs2__default.default.readdir(dp);
|
|
21
|
-
for (const file of files) {
|
|
22
|
-
const actualAge = await getFileAge(`${dp}/${file}`);
|
|
23
|
-
if (actualAge > ageThreshold) {
|
|
24
|
-
await fs2__default.default.remove(`${dp}/${file}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
__name(deleteOlderThan, "deleteOlderThan");
|
|
29
|
-
|
|
30
|
-
exports.deleteOlderThan = deleteOlderThan;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delete files older than a given timestamp
|
|
3
|
-
* @param dp The dirpath to a folder in which to delete files from
|
|
4
|
-
* @param ageThreshold The age in milliseconds to compare against
|
|
5
|
-
*/
|
|
6
|
-
declare function deleteOlderThan(dp: string, ageThreshold: number): Promise<void>;
|
|
7
|
-
|
|
8
|
-
export { deleteOlderThan };
|
package/lib/deleteOlderThan.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delete files older than a given timestamp
|
|
3
|
-
* @param dp The dirpath to a folder in which to delete files from
|
|
4
|
-
* @param ageThreshold The age in milliseconds to compare against
|
|
5
|
-
*/
|
|
6
|
-
declare function deleteOlderThan(dp: string, ageThreshold: number): Promise<void>;
|
|
7
|
-
|
|
8
|
-
export { deleteOlderThan };
|
package/lib/deleteOlderThan.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import fs2 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 fs2.stat(filepath);
|
|
7
|
-
const time = stats.ctimeMs || stats.birthtimeMs || stats.mtimeMs;
|
|
8
|
-
return Date.now() - time;
|
|
9
|
-
}
|
|
10
|
-
__name(getFileAge, "getFileAge");
|
|
11
|
-
|
|
12
|
-
// src/deleteOlderThan.ts
|
|
13
|
-
async function deleteOlderThan(dp, ageThreshold) {
|
|
14
|
-
const files = await fs2.readdir(dp);
|
|
15
|
-
for (const file of files) {
|
|
16
|
-
const actualAge = await getFileAge(`${dp}/${file}`);
|
|
17
|
-
if (actualAge > ageThreshold) {
|
|
18
|
-
await fs2.remove(`${dp}/${file}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
__name(deleteOlderThan, "deleteOlderThan");
|
|
23
|
-
|
|
24
|
-
export { deleteOlderThan };
|
package/lib/getFileAge.cjs
DELETED
|
@@ -1,18 +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 getFileAge(filepath) {
|
|
12
|
-
const stats = await fs__default.default.stat(filepath);
|
|
13
|
-
const time = stats.ctimeMs || stats.birthtimeMs || stats.mtimeMs;
|
|
14
|
-
return Date.now() - time;
|
|
15
|
-
}
|
|
16
|
-
__name(getFileAge, "getFileAge");
|
|
17
|
-
|
|
18
|
-
exports.getFileAge = getFileAge;
|
package/lib/getFileAge.d.cts
DELETED
package/lib/getFileAge.d.ts
DELETED
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 };
|