@bemoje/fs 0.0.12 → 0.1.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 -34
- package/package.json +9 -9
- package/src/index.d.ts +35 -0
- package/src/index.js +39 -0
- package/src/index.js.map +1 -0
- package/src/lib/AppData.d.ts +10 -0
- package/src/lib/AppData.js +24 -0
- package/src/lib/AppData.js.map +1 -0
- package/src/lib/JsonFile.d.ts +78 -0
- package/src/lib/JsonFile.js +146 -0
- package/src/lib/JsonFile.js.map +1 -0
- package/src/lib/LogFile.d.ts +50 -0
- package/src/lib/LogFile.js +158 -0
- package/src/lib/LogFile.js.map +1 -0
- package/src/lib/{absoluteToRelativePath.ts → absoluteToRelativePath.d.ts} +13 -20
- package/src/lib/absoluteToRelativePath.js +25 -0
- package/src/lib/absoluteToRelativePath.js.map +1 -0
- package/src/lib/appendLineToFile.d.ts +11 -0
- package/src/lib/appendLineToFile.js +28 -0
- package/src/lib/appendLineToFile.js.map +1 -0
- package/src/lib/{cleanDirectorySync.ts → cleanDirectorySync.d.ts} +16 -24
- package/src/lib/cleanDirectorySync.js +29 -0
- package/src/lib/cleanDirectorySync.js.map +1 -0
- package/src/lib/{createDirectory.ts → createDirectory.d.ts} +1 -5
- package/src/lib/createDirectory.js +25 -0
- package/src/lib/createDirectory.js.map +1 -0
- package/src/lib/{createDirectorySync.ts → createDirectorySync.d.ts} +1 -6
- package/src/lib/createDirectorySync.js +20 -0
- package/src/lib/createDirectorySync.js.map +1 -0
- package/src/lib/{createFileExtensionFilter.ts → createFileExtensionFilter.d.ts} +1 -14
- package/src/lib/createFileExtensionFilter.js +32 -0
- package/src/lib/createFileExtensionFilter.js.map +1 -0
- package/src/lib/{cwdpath.ts → cwdpath.d.ts} +12 -16
- package/src/lib/cwdpath.js +21 -0
- package/src/lib/cwdpath.js.map +1 -0
- package/src/lib/{deleteDirectory.ts → deleteDirectory.d.ts} +1 -5
- package/src/lib/deleteDirectory.js +23 -0
- package/src/lib/deleteDirectory.js.map +1 -0
- package/src/lib/{deleteDirectorySafe.ts → deleteDirectorySafe.d.ts} +1 -5
- package/src/lib/deleteDirectorySafe.js +25 -0
- package/src/lib/deleteDirectorySafe.js.map +1 -0
- package/src/lib/{deleteDirectorySafeSync.ts → deleteDirectorySafeSync.d.ts} +1 -7
- package/src/lib/deleteDirectorySafeSync.js +23 -0
- package/src/lib/deleteDirectorySafeSync.js.map +1 -0
- package/src/lib/{deleteDirectorySync.ts → deleteDirectorySync.d.ts} +1 -6
- package/src/lib/deleteDirectorySync.js +22 -0
- package/src/lib/deleteDirectorySync.js.map +1 -0
- package/src/lib/{ensureValidWindowsPath.ts → ensureValidWindowsPath.d.ts} +22 -57
- package/src/lib/ensureValidWindowsPath.js +54 -0
- package/src/lib/ensureValidWindowsPath.js.map +1 -0
- package/src/lib/getDiskDrivesWindows.d.ts +1 -0
- package/src/lib/getDiskDrivesWindows.js +19 -0
- package/src/lib/getDiskDrivesWindows.js.map +1 -0
- package/src/lib/getDownloadsDirectory.d.ts +1 -0
- package/src/lib/getDownloadsDirectory.js +11 -0
- package/src/lib/getDownloadsDirectory.js.map +1 -0
- package/src/lib/getHomeDirectory.d.ts +1 -0
- package/src/lib/getHomeDirectory.js +13 -0
- package/src/lib/getHomeDirectory.js.map +1 -0
- package/src/lib/getLastMofifiedFileIn.d.ts +1 -0
- package/src/lib/getLastMofifiedFileIn.js +22 -0
- package/src/lib/getLastMofifiedFileIn.js.map +1 -0
- package/src/lib/getRootDir.d.ts +1 -0
- package/src/lib/getRootDir.js +10 -0
- package/src/lib/getRootDir.js.map +1 -0
- package/src/lib/isWindows.d.ts +1 -0
- package/src/lib/isWindows.js +8 -0
- package/src/lib/isWindows.js.map +1 -0
- package/src/lib/{normalizeFileExtension.ts → normalizeFileExtension.d.ts} +22 -29
- package/src/lib/normalizeFileExtension.js +36 -0
- package/src/lib/normalizeFileExtension.js.map +1 -0
- package/src/lib/readFileLastLines.d.ts +7 -0
- package/src/lib/readFileLastLines.js +18 -0
- package/src/lib/readFileLastLines.js.map +1 -0
- package/src/lib/{readJsonFile.ts → readJsonFile.d.ts} +12 -16
- package/src/lib/readJsonFile.js +23 -0
- package/src/lib/readJsonFile.js.map +1 -0
- package/src/lib/{readJsonFileSync.ts → readJsonFileSync.d.ts} +12 -16
- package/src/lib/readJsonFileSync.js +21 -0
- package/src/lib/readJsonFileSync.js.map +1 -0
- package/src/lib/readPackageJson.d.ts +1 -0
- package/src/lib/readPackageJson.js +15 -0
- package/src/lib/readPackageJson.js.map +1 -0
- package/src/lib/removeIllegalFilenameCharacters.d.ts +1 -0
- package/src/lib/removeIllegalFilenameCharacters.js +8 -0
- package/src/lib/removeIllegalFilenameCharacters.js.map +1 -0
- package/src/lib/tempFile.d.ts +6 -0
- package/src/lib/tempFile.js +26 -0
- package/src/lib/tempFile.js.map +1 -0
- package/src/lib/types/IEnsureValidWindowsPathOptions.d.ts +10 -0
- package/src/lib/types/IEnsureValidWindowsPathOptions.js +3 -0
- package/src/lib/types/IEnsureValidWindowsPathOptions.js.map +1 -0
- package/src/lib/types/ILogFileData.d.ts +5 -0
- package/src/lib/types/ILogFileData.js +3 -0
- package/src/lib/types/ILogFileData.js.map +1 -0
- package/src/lib/unzipFile.d.ts +1 -0
- package/src/lib/unzipFile.js +12 -0
- package/src/lib/unzipFile.js.map +1 -0
- package/src/lib/unzipMergeFiles.d.ts +4 -0
- package/src/lib/unzipMergeFiles.js +29 -0
- package/src/lib/unzipMergeFiles.js.map +1 -0
- package/src/lib/wipeDirectorySafe.d.ts +1 -0
- package/src/lib/wipeDirectorySafe.js +14 -0
- package/src/lib/wipeDirectorySafe.js.map +1 -0
- package/src/lib/{writeJsonFile.ts → writeJsonFile.d.ts} +1 -5
- package/src/lib/writeJsonFile.js +25 -0
- package/src/lib/writeJsonFile.js.map +1 -0
- package/src/lib/{writeJsonFileSync.ts → writeJsonFileSync.d.ts} +1 -5
- package/src/lib/writeJsonFileSync.js +22 -0
- package/src/lib/writeJsonFileSync.js.map +1 -0
- package/LICENSE +0 -21
- package/jest.config.ts +0 -13
- package/project.json +0 -30
- package/src/index.ts +0 -35
- package/src/lib/AppData.ts +0 -25
- package/src/lib/JsonFile.ts +0 -158
- package/src/lib/LogFile.ts +0 -117
- package/src/lib/absoluteToRelativePath.test.ts +0 -11
- package/src/lib/appendLineToFile.test.ts +0 -49
- package/src/lib/appendLineToFile.ts +0 -21
- package/src/lib/cleanDirectorySync.test.ts +0 -57
- package/src/lib/createDirectory.test.ts +0 -14
- package/src/lib/createDirectorySync.test.ts +0 -14
- package/src/lib/createFileExtensionFilter.test.ts +0 -17
- package/src/lib/cwdpath.test.ts +0 -48
- package/src/lib/deleteDirectory.test.ts +0 -24
- package/src/lib/deleteDirectorySafe.test.ts +0 -40
- package/src/lib/deleteDirectorySafeSync.test.ts +0 -30
- package/src/lib/deleteDirectorySync.test.ts +0 -23
- package/src/lib/ensureValidWindowsPath.test.ts +0 -80
- package/src/lib/getDiskDrivesWindows.ts +0 -13
- package/src/lib/getDownloadsDirectory.ts +0 -6
- package/src/lib/getHomeDirectory.ts +0 -7
- package/src/lib/getLastMofifiedFileIn.ts +0 -15
- package/src/lib/getRootDir.ts +0 -5
- package/src/lib/isWindows.ts +0 -3
- package/src/lib/normalizeFileExtension.test.ts +0 -15
- package/src/lib/readFileLastLines.ts +0 -12
- package/src/lib/readJsonFile.test.ts +0 -34
- package/src/lib/readJsonFileSync.test.ts +0 -36
- package/src/lib/readPackageJson.ts +0 -9
- package/src/lib/removeIllegalFilenameCharacters.ts +0 -3
- package/src/lib/tempFile.ts +0 -20
- package/src/lib/types/IEnsureValidWindowsPathOptions.ts +0 -10
- package/src/lib/types/ILogFileData.ts +0 -5
- package/src/lib/unzipFile.ts +0 -5
- package/src/lib/unzipMergeFiles.ts +0 -20
- package/src/lib/wipeDirectorySafe.ts +0 -7
- package/src/lib/writeJsonFile.test.ts +0 -26
- package/src/lib/writeJsonFileSync.test.ts +0 -28
- package/tsconfig.spec.json +0 -9
|
@@ -1,57 +1,22 @@
|
|
|
1
|
-
import { IEnsureValidWindowsPathOptions } from './types/IEnsureValidWindowsPathOptions'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
* - `
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export function ensureValidWindowsPath(path: string, options?: IEnsureValidWindowsPathOptions): boolean {
|
|
24
|
-
const throwOrFalse = (msg: string) => {
|
|
25
|
-
if (options && options.assert === true) {
|
|
26
|
-
throw new Error(`Invalid windows path. ${msg} | input received: ${path}`)
|
|
27
|
-
}
|
|
28
|
-
return false
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (path.length === 0) {
|
|
32
|
-
return throwOrFalse('Path string is length 0.')
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (path.indexOf('/') !== -1 && path.indexOf('\\') !== -1) {
|
|
36
|
-
return throwOrFalse('Path contains both backslash and forward slash.')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const maxLength = (options && options.extendedMaxLength ? 32767 : 260) - 12
|
|
40
|
-
if (path.length > maxLength) {
|
|
41
|
-
return throwOrFalse(`Maximum length of ${maxLength} exceeded`)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let noDriveLetter = path
|
|
45
|
-
if (/^\w:(\\|\/)/g.test(path)) {
|
|
46
|
-
noDriveLetter = path.substring(2)
|
|
47
|
-
}
|
|
48
|
-
if (/[<>"|?*:]/g.test(noDriveLetter)) {
|
|
49
|
-
return throwOrFalse(`Illegal characters in: ${path} | Illegal characters are: <>"|?:*`)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (/(\\|\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\|\/)|$)/g.test(path)) {
|
|
53
|
-
return throwOrFalse('Illegal name in path string')
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return true
|
|
57
|
-
}
|
|
1
|
+
import { IEnsureValidWindowsPathOptions } from './types/IEnsureValidWindowsPathOptions';
|
|
2
|
+
/**
|
|
3
|
+
* Check whether a provided windows filesystem path string is valid according to:
|
|
4
|
+
* https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
|
5
|
+
* @param path The path to validate.
|
|
6
|
+
* @returns A boolean indicating whether the path is valid. If the `assert` option is true, the function will throw an error instead of returning false.
|
|
7
|
+
* @throws Will throw an error if the `assert` option is true and the path is invalid.
|
|
8
|
+
* @param options An optional object that may contain the following properties:
|
|
9
|
+
* - `assert`: If true, the function will throw an error if the path is invalid. Default is false.
|
|
10
|
+
* - `extendedMaxLength`: If true, the function will allow paths up to 32767 characters long. Default is false.
|
|
11
|
+
* @example ```ts
|
|
12
|
+
* ensureValidWindowsPath('C:\\Users\\User\\Documents\\file.txt');;
|
|
13
|
+
* //=> true
|
|
14
|
+
* ensureValidWindowsPath('C:/Users/User/Documents/file.txt');;
|
|
15
|
+
* //=> false
|
|
16
|
+
* ensureValidWindowsPath('C:\\Users\\User\\Documents\\file.txt', { assert: true });;
|
|
17
|
+
* //=> throws an error
|
|
18
|
+
* ensureValidWindowsPath('C:\\Users\\User\\Documents\\file.txt', { extendedMaxLength: true });;
|
|
19
|
+
* //=> true
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function ensureValidWindowsPath(path: string, options?: IEnsureValidWindowsPathOptions): boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureValidWindowsPath = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Check whether a provided windows filesystem path string is valid according to:
|
|
6
|
+
* https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
|
7
|
+
* @param path The path to validate.
|
|
8
|
+
* @returns A boolean indicating whether the path is valid. If the `assert` option is true, the function will throw an error instead of returning false.
|
|
9
|
+
* @throws Will throw an error if the `assert` option is true and the path is invalid.
|
|
10
|
+
* @param options An optional object that may contain the following properties:
|
|
11
|
+
* - `assert`: If true, the function will throw an error if the path is invalid. Default is false.
|
|
12
|
+
* - `extendedMaxLength`: If true, the function will allow paths up to 32767 characters long. Default is false.
|
|
13
|
+
* @example ```ts
|
|
14
|
+
* ensureValidWindowsPath('C:\\Users\\User\\Documents\\file.txt');;
|
|
15
|
+
* //=> true
|
|
16
|
+
* ensureValidWindowsPath('C:/Users/User/Documents/file.txt');;
|
|
17
|
+
* //=> false
|
|
18
|
+
* ensureValidWindowsPath('C:\\Users\\User\\Documents\\file.txt', { assert: true });;
|
|
19
|
+
* //=> throws an error
|
|
20
|
+
* ensureValidWindowsPath('C:\\Users\\User\\Documents\\file.txt', { extendedMaxLength: true });;
|
|
21
|
+
* //=> true
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function ensureValidWindowsPath(path, options) {
|
|
25
|
+
const throwOrFalse = (msg) => {
|
|
26
|
+
if (options && options.assert === true) {
|
|
27
|
+
throw new Error(`Invalid windows path. ${msg} | input received: ${path}`);
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
31
|
+
if (path.length === 0) {
|
|
32
|
+
return throwOrFalse('Path string is length 0.');
|
|
33
|
+
}
|
|
34
|
+
if (path.indexOf('/') !== -1 && path.indexOf('\\') !== -1) {
|
|
35
|
+
return throwOrFalse('Path contains both backslash and forward slash.');
|
|
36
|
+
}
|
|
37
|
+
const maxLength = (options && options.extendedMaxLength ? 32767 : 260) - 12;
|
|
38
|
+
if (path.length > maxLength) {
|
|
39
|
+
return throwOrFalse(`Maximum length of ${maxLength} exceeded`);
|
|
40
|
+
}
|
|
41
|
+
let noDriveLetter = path;
|
|
42
|
+
if (/^\w:(\\|\/)/g.test(path)) {
|
|
43
|
+
noDriveLetter = path.substring(2);
|
|
44
|
+
}
|
|
45
|
+
if (/[<>"|?*:]/g.test(noDriveLetter)) {
|
|
46
|
+
return throwOrFalse(`Illegal characters in: ${path} | Illegal characters are: <>"|?:*`);
|
|
47
|
+
}
|
|
48
|
+
if (/(\\|\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\|\/)|$)/g.test(path)) {
|
|
49
|
+
return throwOrFalse('Illegal name in path string');
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
exports.ensureValidWindowsPath = ensureValidWindowsPath;
|
|
54
|
+
//# sourceMappingURL=ensureValidWindowsPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureValidWindowsPath.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/ensureValidWindowsPath.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,sBAAsB,CAAC,IAAY,EAAE,OAAwC;IAC3F,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE;QACnC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,wBAAwB,IAAI,EAAE,CAAC,CAAA;SAC5E;QACD,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,OAAO,YAAY,CAAC,0BAA0B,CAAC,CAAA;KAChD;IAED,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;QACzD,OAAO,YAAY,CAAC,iDAAiD,CAAC,CAAA;KACvE;IAED,MAAM,SAAS,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;IAC3E,IAAI,IAAI,CAAC,MAAM,GAAG,SAAS,EAAE;QAC3B,OAAO,YAAY,CAAC,qBAAqB,SAAS,WAAW,CAAC,CAAA;KAC/D;IAED,IAAI,aAAa,GAAG,IAAI,CAAA;IACxB,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC7B,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;KAClC;IACD,IAAI,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;QACpC,OAAO,YAAY,CAAC,0BAA0B,IAAI,sCAAsC,CAAC,CAAA;KAC1F;IAED,IAAI,wDAAwD,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACvE,OAAO,YAAY,CAAC,6BAA6B,CAAC,CAAA;KACnD;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAlCD,wDAkCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDiskDrivesWindows(): string[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDiskDrivesWindows = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const isWindows_1 = require("./isWindows");
|
|
8
|
+
function getDiskDrivesWindows() {
|
|
9
|
+
if (!(0, isWindows_1.isWindows)())
|
|
10
|
+
throw new Error('This function is only available on Windows.');
|
|
11
|
+
return (0, child_process_1.execSync)('wmic logicaldisk get name')
|
|
12
|
+
.toString()
|
|
13
|
+
.split('\n')
|
|
14
|
+
.map((s) => s.trim())
|
|
15
|
+
.filter((s) => /^[a-z]:/i.test(s))
|
|
16
|
+
.map((s) => s.substring(0, 2) + path_1.default.sep);
|
|
17
|
+
}
|
|
18
|
+
exports.getDiskDrivesWindows = getDiskDrivesWindows;
|
|
19
|
+
//# sourceMappingURL=getDiskDrivesWindows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDiskDrivesWindows.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/getDiskDrivesWindows.ts"],"names":[],"mappings":";;;;AAAA,iDAAwC;AACxC,wDAAuB;AACvB,2CAAuC;AAEvC,SAAgB,oBAAoB;IAClC,IAAI,CAAC,IAAA,qBAAS,GAAE;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAChF,OAAO,IAAA,wBAAQ,EAAC,2BAA2B,CAAC;SACzC,QAAQ,EAAE;SACV,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,cAAI,CAAC,GAAG,CAAC,CAAA;AAC7C,CAAC;AARD,oDAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDownloadsDirectory(): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDownloadsDirectory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const getHomeDirectory_1 = require("./getHomeDirectory");
|
|
7
|
+
function getDownloadsDirectory() {
|
|
8
|
+
return path_1.default.join((0, getHomeDirectory_1.getHomeDirectory)(), 'Downloads');
|
|
9
|
+
}
|
|
10
|
+
exports.getDownloadsDirectory = getDownloadsDirectory;
|
|
11
|
+
//# sourceMappingURL=getDownloadsDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDownloadsDirectory.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/getDownloadsDirectory.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AACvB,yDAAqD;AAErD,SAAgB,qBAAqB;IACnC,OAAO,cAAI,CAAC,IAAI,CAAC,IAAA,mCAAgB,GAAE,EAAE,WAAW,CAAC,CAAA;AACnD,CAAC;AAFD,sDAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getHomeDirectory(): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHomeDirectory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
function getHomeDirectory() {
|
|
7
|
+
const home = path_1.default.resolve(process.env['HOME'] || process.env['USERPROFILE'] || '');
|
|
8
|
+
if (!home)
|
|
9
|
+
throw new Error('Home directory not found');
|
|
10
|
+
return home;
|
|
11
|
+
}
|
|
12
|
+
exports.getHomeDirectory = getHomeDirectory;
|
|
13
|
+
//# sourceMappingURL=getHomeDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHomeDirectory.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/getHomeDirectory.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AAEvB,SAAgB,gBAAgB;IAC9B,MAAM,IAAI,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;IAClF,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IACtD,OAAO,IAAI,CAAA;AACb,CAAC;AAJD,4CAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLastMofifiedFileIn(dirpath: string): Promise<string>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLastMofifiedFileIn = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
function getLastMofifiedFileIn(dirpath) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const children = yield fs_1.default.promises.readdir(dirpath);
|
|
10
|
+
const filtered = children
|
|
11
|
+
.map((fname) => {
|
|
12
|
+
const fpath = path_1.default.join(dirpath, fname);
|
|
13
|
+
const stat = fs_1.default.statSync(fpath);
|
|
14
|
+
return [fpath, stat.mtimeMs, stat.isFile()];
|
|
15
|
+
})
|
|
16
|
+
.filter((a) => a[2]);
|
|
17
|
+
const sorted = filtered.sort((a, b) => b[1] - a[1]);
|
|
18
|
+
return sorted[0][0];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.getLastMofifiedFileIn = getLastMofifiedFileIn;
|
|
22
|
+
//# sourceMappingURL=getLastMofifiedFileIn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLastMofifiedFileIn.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/getLastMofifiedFileIn.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AACnB,wDAAuB;AAEvB,SAAsB,qBAAqB,CAAC,OAAe;;QACzD,MAAM,QAAQ,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QACnD,MAAM,QAAQ,GAAG,QAAQ;aACtB,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE;YACrB,MAAM,KAAK,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;YACvC,MAAM,IAAI,GAAG,YAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YAC/B,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;QAC7C,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAgC,CAAA;QACrD,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACnD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACrB,CAAC;CAAA;AAXD,sDAWC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRootDir(): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRootDir = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
function getRootDir() {
|
|
7
|
+
return path_1.default.parse(process.cwd()).root;
|
|
8
|
+
}
|
|
9
|
+
exports.getRootDir = getRootDir;
|
|
10
|
+
//# sourceMappingURL=getRootDir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRootDir.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/getRootDir.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AAEvB,SAAgB,UAAU;IACxB,OAAO,cAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAA;AACvC,CAAC;AAFD,gCAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isWindows(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isWindows.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/isWindows.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS;IACvB,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACzC,CAAC;AAFD,8BAEC"}
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalize a file extension to the form: .[ext]
|
|
3
|
-
* Anything before the last "." is not returned.
|
|
4
|
-
* @returns The normalized file extension.
|
|
5
|
-
* @throws If the extension contains illegal characters.
|
|
6
|
-
* @param ext file extension
|
|
7
|
-
* @example ```ts
|
|
8
|
-
* normalizeFileExtension('jpg');;
|
|
9
|
-
* //=> '.jpg'
|
|
10
|
-
* normalizeFileExtension('.jpg');;
|
|
11
|
-
* //=> '.jpg'
|
|
12
|
-
* normalizeFileExtension('..jpg');;
|
|
13
|
-
* //=> '.jpg'
|
|
14
|
-
* normalizeFileExtension('');;
|
|
15
|
-
* //=> ''
|
|
16
|
-
* normalizeFileExtension('.');;
|
|
17
|
-
* //=> ''
|
|
18
|
-
* normalizeFileExtension('jpg|png');;
|
|
19
|
-
* //=> Error
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export function normalizeFileExtension(ext: string): string
|
|
23
|
-
if (ext === '' || ext === '.') return ''
|
|
24
|
-
if (/[<>"|?*:]/g.test(ext)) {
|
|
25
|
-
throw new Error(`Illegal characters in file extension: ${ext} | Illegal characters are: <>"|?:*`)
|
|
26
|
-
}
|
|
27
|
-
if (!ext.includes('.')) return '.' + ext
|
|
28
|
-
return ext.substring(ext.lastIndexOf('.'))
|
|
29
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a file extension to the form: .[ext]
|
|
3
|
+
* Anything before the last "." is not returned.
|
|
4
|
+
* @returns The normalized file extension.
|
|
5
|
+
* @throws If the extension contains illegal characters.
|
|
6
|
+
* @param ext file extension
|
|
7
|
+
* @example ```ts
|
|
8
|
+
* normalizeFileExtension('jpg');;
|
|
9
|
+
* //=> '.jpg'
|
|
10
|
+
* normalizeFileExtension('.jpg');;
|
|
11
|
+
* //=> '.jpg'
|
|
12
|
+
* normalizeFileExtension('..jpg');;
|
|
13
|
+
* //=> '.jpg'
|
|
14
|
+
* normalizeFileExtension('');;
|
|
15
|
+
* //=> ''
|
|
16
|
+
* normalizeFileExtension('.');;
|
|
17
|
+
* //=> ''
|
|
18
|
+
* normalizeFileExtension('jpg|png');;
|
|
19
|
+
* //=> Error
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizeFileExtension(ext: string): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeFileExtension = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Normalize a file extension to the form: .[ext]
|
|
6
|
+
* Anything before the last "." is not returned.
|
|
7
|
+
* @returns The normalized file extension.
|
|
8
|
+
* @throws If the extension contains illegal characters.
|
|
9
|
+
* @param ext file extension
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* normalizeFileExtension('jpg');;
|
|
12
|
+
* //=> '.jpg'
|
|
13
|
+
* normalizeFileExtension('.jpg');;
|
|
14
|
+
* //=> '.jpg'
|
|
15
|
+
* normalizeFileExtension('..jpg');;
|
|
16
|
+
* //=> '.jpg'
|
|
17
|
+
* normalizeFileExtension('');;
|
|
18
|
+
* //=> ''
|
|
19
|
+
* normalizeFileExtension('.');;
|
|
20
|
+
* //=> ''
|
|
21
|
+
* normalizeFileExtension('jpg|png');;
|
|
22
|
+
* //=> Error
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function normalizeFileExtension(ext) {
|
|
26
|
+
if (ext === '' || ext === '.')
|
|
27
|
+
return '';
|
|
28
|
+
if (/[<>"|?*:]/g.test(ext)) {
|
|
29
|
+
throw new Error(`Illegal characters in file extension: ${ext} | Illegal characters are: <>"|?:*`);
|
|
30
|
+
}
|
|
31
|
+
if (!ext.includes('.'))
|
|
32
|
+
return '.' + ext;
|
|
33
|
+
return ext.substring(ext.lastIndexOf('.'));
|
|
34
|
+
}
|
|
35
|
+
exports.normalizeFileExtension = normalizeFileExtension;
|
|
36
|
+
//# sourceMappingURL=normalizeFileExtension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeFileExtension.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/normalizeFileExtension.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,sBAAsB,CAAC,GAAW;IAChD,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,EAAE,CAAA;IACxC,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,yCAAyC,GAAG,sCAAsC,CAAC,CAAA;KACpG;IACD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,GAAG,GAAG,CAAA;IACxC,OAAO,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;AAC5C,CAAC;AAPD,wDAOC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the last n lines of a file.
|
|
3
|
+
* @param filepath The path to the file.
|
|
4
|
+
* @param n The number of lines to read.
|
|
5
|
+
* @example await readLastLines.read('path/to/file.log', 50)
|
|
6
|
+
*/
|
|
7
|
+
export declare function readFileLastLines(filepath: string, n: number): Promise<string>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readFileLastLines = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const read_last_lines_1 = tslib_1.__importDefault(require("read-last-lines"));
|
|
6
|
+
/**
|
|
7
|
+
* Read the last n lines of a file.
|
|
8
|
+
* @param filepath The path to the file.
|
|
9
|
+
* @param n The number of lines to read.
|
|
10
|
+
* @example await readLastLines.read('path/to/file.log', 50)
|
|
11
|
+
*/
|
|
12
|
+
function readFileLastLines(filepath, n) {
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
return yield read_last_lines_1.default.read(filepath, n, 'utf8');
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.readFileLastLines = readFileLastLines;
|
|
18
|
+
//# sourceMappingURL=readFileLastLines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readFileLastLines.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/readFileLastLines.ts"],"names":[],"mappings":";;;;AAAA,8EAA2C;AAE3C;;;;;GAKG;AACH,SAAsB,iBAAiB,CAAC,QAAgB,EAAE,CAAS;;QACjE,OAAO,MAAM,yBAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;IACtD,CAAC;CAAA;AAFD,8CAEC"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
export async function readJsonFile<T>(filepath: string): Promise<T> {
|
|
15
|
-
return JSON.parse(await fs.promises.readFile(filepath, 'utf8'))
|
|
16
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Reads a JSON file from the given filepath and returns its content as a Promise.
|
|
3
|
+
* The Promise will resolve with the parsed JSON content as an object of type T.
|
|
4
|
+
* @template T The expected return type of the JSON object.
|
|
5
|
+
* @param filepath The path to the JSON file to read.
|
|
6
|
+
* @returns A Promise that resolves with the parsed JSON content as an object of type T.
|
|
7
|
+
* @throws Will throw an error if reading the file fails for any reason.
|
|
8
|
+
* @example ```ts
|
|
9
|
+
* const data: MyType = await readJsonFile<MyType>('path/to/myfile.json');
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function readJsonFile<T>(filepath: string): Promise<T>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readJsonFile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
/**
|
|
7
|
+
* Reads a JSON file from the given filepath and returns its content as a Promise.
|
|
8
|
+
* The Promise will resolve with the parsed JSON content as an object of type T.
|
|
9
|
+
* @template T The expected return type of the JSON object.
|
|
10
|
+
* @param filepath The path to the JSON file to read.
|
|
11
|
+
* @returns A Promise that resolves with the parsed JSON content as an object of type T.
|
|
12
|
+
* @throws Will throw an error if reading the file fails for any reason.
|
|
13
|
+
* @example ```ts
|
|
14
|
+
* const data: MyType = await readJsonFile<MyType>('path/to/myfile.json');
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function readJsonFile(filepath) {
|
|
18
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return JSON.parse(yield fs_1.default.promises.readFile(filepath, 'utf8'));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.readJsonFile = readJsonFile;
|
|
23
|
+
//# sourceMappingURL=readJsonFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readJsonFile.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/readJsonFile.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AAEnB;;;;;;;;;;GAUG;AACH,SAAsB,YAAY,CAAI,QAAgB;;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;IACjE,CAAC;CAAA;AAFD,oCAEC"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
export function readJsonFileSync<T>(filepath: string): T {
|
|
15
|
-
return JSON.parse(fs.readFileSync(filepath, 'utf8'))
|
|
16
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Reads a JSON file synchronously and returns a Promise that resolves with the parsed JSON data.
|
|
3
|
+
* @template T The expected return type of the JSON data.
|
|
4
|
+
* @param filepath The path to the JSON file to read.
|
|
5
|
+
* @returns A Promise that resolves with the parsed JSON data.
|
|
6
|
+
* @throws If the file cannot be read or the content cannot be parsed as JSON.
|
|
7
|
+
* @example ```ts
|
|
8
|
+
* const data = await readJsonFileSync<MyType>('/path/to/file.json');
|
|
9
|
+
* console.log(data);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function readJsonFileSync<T>(filepath: string): T;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readJsonFileSync = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
/**
|
|
7
|
+
* Reads a JSON file synchronously and returns a Promise that resolves with the parsed JSON data.
|
|
8
|
+
* @template T The expected return type of the JSON data.
|
|
9
|
+
* @param filepath The path to the JSON file to read.
|
|
10
|
+
* @returns A Promise that resolves with the parsed JSON data.
|
|
11
|
+
* @throws If the file cannot be read or the content cannot be parsed as JSON.
|
|
12
|
+
* @example ```ts
|
|
13
|
+
* const data = await readJsonFileSync<MyType>('/path/to/file.json');
|
|
14
|
+
* console.log(data);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function readJsonFileSync(filepath) {
|
|
18
|
+
return JSON.parse(fs_1.default.readFileSync(filepath, 'utf8'));
|
|
19
|
+
}
|
|
20
|
+
exports.readJsonFileSync = readJsonFileSync;
|
|
21
|
+
//# sourceMappingURL=readJsonFileSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readJsonFileSync.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/readJsonFileSync.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AAEnB;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAAI,QAAgB;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;AACtD,CAAC;AAFD,4CAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readPackageJson(projectRoot?: string): Record<string, any> | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readPackageJson = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const readJsonFileSync_1 = require("./readJsonFileSync");
|
|
8
|
+
function readPackageJson(projectRoot = process.cwd()) {
|
|
9
|
+
const filepath = path_1.default.join(projectRoot, 'package.json');
|
|
10
|
+
if (!fs_1.default.existsSync(filepath))
|
|
11
|
+
return;
|
|
12
|
+
return (0, readJsonFileSync_1.readJsonFileSync)(filepath);
|
|
13
|
+
}
|
|
14
|
+
exports.readPackageJson = readPackageJson;
|
|
15
|
+
//# sourceMappingURL=readPackageJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readPackageJson.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/readPackageJson.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AACnB,wDAAuB;AACvB,yDAAqD;AAErD,SAAgB,eAAe,CAAC,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;IACzD,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;IACvD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAM;IACpC,OAAO,IAAA,mCAAgB,EAAC,QAAQ,CAAC,CAAA;AACnC,CAAC;AAJD,0CAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function removeIllegalFilenameCharacters(string: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeIllegalFilenameCharacters = void 0;
|
|
4
|
+
function removeIllegalFilenameCharacters(string) {
|
|
5
|
+
return string.replace(/[/\\?%*:|"<>]/g, '');
|
|
6
|
+
}
|
|
7
|
+
exports.removeIllegalFilenameCharacters = removeIllegalFilenameCharacters;
|
|
8
|
+
//# sourceMappingURL=removeIllegalFilenameCharacters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeIllegalFilenameCharacters.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/removeIllegalFilenameCharacters.ts"],"names":[],"mappings":";;;AAAA,SAAgB,+BAA+B,CAAC,MAAc;IAC5D,OAAO,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;AAC7C,CAAC;AAFD,0EAEC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a temporary file and deletes it after the callback has finished.
|
|
3
|
+
* @param fileExtension - The file extension to use for the temporary file.
|
|
4
|
+
* @param callback - The callback to execute with the temporary file path. The callback can return a promise and the temporary file will not be deleted until the promise has resolved or rejected.
|
|
5
|
+
*/
|
|
6
|
+
export declare function tempFile(fileExtension: string, callback: (fpath: string) => void | Promise<void>): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tempFile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
/**
|
|
8
|
+
* Creates a temporary file and deletes it after the callback has finished.
|
|
9
|
+
* @param fileExtension - The file extension to use for the temporary file.
|
|
10
|
+
* @param callback - The callback to execute with the temporary file path. The callback can return a promise and the temporary file will not be deleted until the promise has resolved or rejected.
|
|
11
|
+
*/
|
|
12
|
+
function tempFile(fileExtension, callback) {
|
|
13
|
+
const dir = path_1.default.join(process.env['TEMP'], 'bemoje', 'temp');
|
|
14
|
+
const fpath = path_1.default.join(dir, Date.now() + fileExtension);
|
|
15
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
16
|
+
const prom = callback(fpath);
|
|
17
|
+
if (prom instanceof Promise) {
|
|
18
|
+
const rm = () => fs_1.default.rmSync(fpath);
|
|
19
|
+
prom.then(rm).catch(rm);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
fs_1.default.rmSync(fpath);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.tempFile = tempFile;
|
|
26
|
+
//# sourceMappingURL=tempFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempFile.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/tempFile.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AACnB,wDAAuB;AAEvB;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,aAAqB,EAAE,QAAiD;IAC/F,MAAM,GAAG,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC7D,MAAM,KAAK,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC,CAAA;IACxD,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACtC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC5B,IAAI,IAAI,YAAY,OAAO,EAAE;QAC3B,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC,YAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;KACxB;SAAM;QACL,YAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;KACjB;AACH,CAAC;AAXD,4BAWC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEnsureValidWindowsPathOptions.js","sourceRoot":"","sources":["../../../../../../packages/fs/src/lib/types/IEnsureValidWindowsPathOptions.ts"],"names":[],"mappings":""}
|