@bemoje/fs 0.0.2 → 0.0.4

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 (67) hide show
  1. package/README.md +2 -3
  2. package/dist/index.cjs.js +2 -2
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.esm.js +2 -2
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/types/index.d.ts +30 -0
  7. package/dist/types/index.d.ts.map +1 -0
  8. package/dist/types/lib/absoluteToRelativePath.d.ts +14 -0
  9. package/dist/types/lib/absoluteToRelativePath.d.ts.map +1 -0
  10. package/dist/types/lib/appendLineToFile.d.ts +12 -0
  11. package/dist/types/lib/appendLineToFile.d.ts.map +1 -0
  12. package/dist/types/lib/cleanDirectorySync.d.ts +17 -0
  13. package/dist/types/lib/cleanDirectorySync.d.ts.map +1 -0
  14. package/dist/types/lib/createDirectory.d.ts +14 -0
  15. package/dist/types/lib/createDirectory.d.ts.map +1 -0
  16. package/dist/types/lib/createDirectorySync.d.ts +11 -0
  17. package/dist/types/lib/createDirectorySync.d.ts.map +1 -0
  18. package/dist/types/lib/createFileExtensionFilter.d.ts +14 -0
  19. package/dist/types/lib/createFileExtensionFilter.d.ts.map +1 -0
  20. package/dist/types/lib/cwdpath.d.ts +13 -0
  21. package/dist/types/lib/cwdpath.d.ts.map +1 -0
  22. package/dist/types/lib/deleteDirectory.d.ts +13 -0
  23. package/dist/types/lib/deleteDirectory.d.ts.map +1 -0
  24. package/dist/types/lib/deleteDirectorySafe.d.ts +14 -0
  25. package/dist/types/lib/deleteDirectorySafe.d.ts.map +1 -0
  26. package/dist/types/lib/deleteDirectorySafeSync.d.ts +12 -0
  27. package/dist/types/lib/deleteDirectorySafeSync.d.ts.map +1 -0
  28. package/dist/types/lib/deleteDirectorySync.d.ts +13 -0
  29. package/dist/types/lib/deleteDirectorySync.d.ts.map +1 -0
  30. package/dist/types/lib/ensureValidWindowsPath.d.ts +23 -0
  31. package/dist/types/lib/ensureValidWindowsPath.d.ts.map +1 -0
  32. package/dist/types/lib/getDiskDrivesWindows.d.ts +2 -0
  33. package/dist/types/lib/getDiskDrivesWindows.d.ts.map +1 -0
  34. package/dist/types/lib/getDownloadsDirectory.d.ts +2 -0
  35. package/dist/types/lib/getDownloadsDirectory.d.ts.map +1 -0
  36. package/dist/types/lib/getHomeDirectory.d.ts +2 -0
  37. package/dist/types/lib/getHomeDirectory.d.ts.map +1 -0
  38. package/dist/types/lib/getLastMofifiedFileIn.d.ts +2 -0
  39. package/dist/types/lib/getLastMofifiedFileIn.d.ts.map +1 -0
  40. package/dist/types/lib/getRootDir.d.ts +2 -0
  41. package/dist/types/lib/getRootDir.d.ts.map +1 -0
  42. package/dist/types/lib/isWindows.d.ts +2 -0
  43. package/dist/types/lib/isWindows.d.ts.map +1 -0
  44. package/dist/types/lib/normalizeFileExtension.d.ts +23 -0
  45. package/dist/types/lib/normalizeFileExtension.d.ts.map +1 -0
  46. package/dist/types/lib/readJsonFile.d.ts +13 -0
  47. package/dist/types/lib/readJsonFile.d.ts.map +1 -0
  48. package/dist/types/lib/readJsonFileSync.d.ts +13 -0
  49. package/dist/types/lib/readJsonFileSync.d.ts.map +1 -0
  50. package/dist/types/lib/readPackageJson.d.ts +2 -0
  51. package/dist/types/lib/readPackageJson.d.ts.map +1 -0
  52. package/dist/types/lib/removeIllegalFilenameCharacters.d.ts +2 -0
  53. package/dist/types/lib/removeIllegalFilenameCharacters.d.ts.map +1 -0
  54. package/dist/types/lib/types/IEnsureValidWindowsPathOptions.d.ts +11 -0
  55. package/dist/types/lib/types/IEnsureValidWindowsPathOptions.d.ts.map +1 -0
  56. package/dist/types/lib/unzipFile.d.ts +2 -0
  57. package/dist/types/lib/unzipFile.d.ts.map +1 -0
  58. package/dist/types/lib/unzipMergeFiles.d.ts +5 -0
  59. package/dist/types/lib/unzipMergeFiles.d.ts.map +1 -0
  60. package/dist/types/lib/wipeDirectorySafe.d.ts +2 -0
  61. package/dist/types/lib/wipeDirectorySafe.d.ts.map +1 -0
  62. package/dist/types/lib/writeJsonFile.d.ts +15 -0
  63. package/dist/types/lib/writeJsonFile.d.ts.map +1 -0
  64. package/dist/types/lib/writeJsonFileSync.d.ts +14 -0
  65. package/dist/types/lib/writeJsonFileSync.d.ts.map +1 -0
  66. package/package.json +10 -39
  67. package/project.json +8 -0
@@ -0,0 +1,30 @@
1
+ export * from './lib/absoluteToRelativePath';
2
+ export * from './lib/appendLineToFile';
3
+ export * from './lib/cleanDirectorySync';
4
+ export * from './lib/createDirectory';
5
+ export * from './lib/createDirectorySync';
6
+ export * from './lib/createFileExtensionFilter';
7
+ export * from './lib/cwdpath';
8
+ export * from './lib/deleteDirectory';
9
+ export * from './lib/deleteDirectorySafe';
10
+ export * from './lib/deleteDirectorySafeSync';
11
+ export * from './lib/deleteDirectorySync';
12
+ export * from './lib/ensureValidWindowsPath';
13
+ export * from './lib/getDiskDrivesWindows';
14
+ export * from './lib/getDownloadsDirectory';
15
+ export * from './lib/getHomeDirectory';
16
+ export * from './lib/getLastMofifiedFileIn';
17
+ export * from './lib/getRootDir';
18
+ export * from './lib/isWindows';
19
+ export * from './lib/normalizeFileExtension';
20
+ export * from './lib/readJsonFile';
21
+ export * from './lib/readJsonFileSync';
22
+ export * from './lib/readPackageJson';
23
+ export * from './lib/removeIllegalFilenameCharacters';
24
+ export * from './lib/types/IEnsureValidWindowsPathOptions';
25
+ export * from './lib/unzipFile';
26
+ export * from './lib/unzipMergeFiles';
27
+ export * from './lib/wipeDirectorySafe';
28
+ export * from './lib/writeJsonFile';
29
+ export * from './lib/writeJsonFileSync';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uCAAuC,CAAA;AACrD,cAAc,4CAA4C,CAAA;AAC1D,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * If the filepath is somewhere in the current working directory, it can be converted into a relative path.
3
+ * @remarks This function takes an absolute path as input and returns a relative path. It replaces the current working directory in the path with an empty string,
4
+ * replaces all backslashes with forward slashes, and removes any leading forward slashes.
5
+ * @param workingDirectory The directory relative to which the path should be converted. Defaults to the current working directory.
6
+ * @returns The relative path.
7
+ * @param absolute the absolute filepath to convert.
8
+ * @example ```ts
9
+ * absoluteToRelativePath(__filename)
10
+ * //=> 'src/absoluteToRelativePath.ts'
11
+ * ```
12
+ */
13
+ export declare function absoluteToRelativePath(absolute: string, workingDirectory?: string): string;
14
+ //# sourceMappingURL=absoluteToRelativePath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"absoluteToRelativePath.d.ts","sourceRoot":"","sources":["../../../src/lib/absoluteToRelativePath.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,SAAgB,GAAG,MAAM,CAIjG"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Append a line to a file. Creates the file if it does not exist.
3
+ * @param filepath The path of the file.
4
+ * @param line The string data to append.
5
+ * @returns A Promise that resolves when the line has been appended to the file.
6
+ * @throws Will throw an error if the operation fails.
7
+ * @example ```ts
8
+ * await appendLineToFile('/path/to/file', 'This is a new line')
9
+ * ```
10
+ */
11
+ export declare function appendLineToFile(filepath: string, line: string, linebreakBefore?: boolean): Promise<void>;
12
+ //# sourceMappingURL=appendLineToFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appendLineToFile.d.ts","sourceRoot":"","sources":["../../../src/lib/appendLineToFile.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7G"}
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" />
2
+ import type { Stats } from 'fs';
3
+ /**
4
+ * Synchronously cleans a directory by removing files that satisfy a given predicate.
5
+ * @remarks This function is a part of the File System module.
6
+ * @param dirpath - The path to the directory that needs to be cleaned.
7
+ * @param predicate - A function that takes a filepath and its stats as arguments and returns a boolean. If the function returns true for a file, that file is removed from the directory.
8
+ * @throws If the directory at the provided path does not exist or cannot be read.
9
+ * @example ```ts
10
+ * import { Stats } from 'fs';
11
+ * const dirpath = './my-directory';
12
+ * const predicate = (filepath: string, stat: Stats) => stat.size > 1024;
13
+ * cleanDirectorySync(dirpath, predicate);
14
+ * ```
15
+ */
16
+ export declare function cleanDirectorySync(dirpath: string, predicate: (filepath: string, stat: Stats) => boolean): void;
17
+ //# sourceMappingURL=cleanDirectorySync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanDirectorySync.d.ts","sourceRoot":"","sources":["../../../src/lib/cleanDirectorySync.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,CAAA;AAI/B;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,KAAK,OAAO,GAAG,IAAI,CAM/G"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Create a directory at a given path if it does not exist.
3
+ * Automatically creates parent directories if they do not exist.
4
+ * @param dirpath The path where the directory should be created.
5
+ * @returns The path of the directory.
6
+ * @throws Will throw an error if the directory cannot be created.
7
+ * @example ```ts
8
+ * createDirectory('/path/to/directory').then((dirpath) => {
9
+ * //=> `Directory created at ${dirpath}`
10
+ * });
11
+ * ```
12
+ */
13
+ export declare function createDirectory(dirpath: string): Promise<string>;
14
+ //# sourceMappingURL=createDirectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDirectory.d.ts","sourceRoot":"","sources":["../../../src/lib/createDirectory.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtE"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Create a directory at a given path if it does not exist.
3
+ * Automatically creates parent directories if they do not exist.
4
+ * @param dirpath The path where the directory should be created.
5
+ * @returns The path of the directory.
6
+ * @example ```ts
7
+ * createDirectorySync('/path/to/directory')
8
+ * ```
9
+ */
10
+ export declare function createDirectorySync(dirpath: string): string;
11
+ //# sourceMappingURL=createDirectorySync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDirectorySync.d.ts","sourceRoot":"","sources":["../../../src/lib/createDirectorySync.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG3D"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Takes a list of file extensions and returns a filter function that returns true if a filepath/filename passed to it contains one of the given file extensions.
3
+ * @remarks If no file extensions are provided, the filter will always return true.
4
+ * @returns A function that takes a filepath and returns true if the filepath has one of the specified file extensions, false otherwise.
5
+ * @param fileExtensions file extensions
6
+ * @example ```ts
7
+ * createFileExtensionFilter('.ts', '.tsx')('index.ts');;
8
+ * //=> true
9
+ * createFileExtensionFilter('.ts', '.tsx')('index.js');;
10
+ * //=> false
11
+ * ```
12
+ */
13
+ export declare function createFileExtensionFilter(...fileExtensions: string[]): (filepath: string) => boolean;
14
+ //# sourceMappingURL=createFileExtensionFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFileExtensionFilter.d.ts","sourceRoot":"","sources":["../../../src/lib/createFileExtensionFilter.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,cAAc,EAAE,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAUpG"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Joins the given path segments to the current working directory path, and normalizes the resulting path.
3
+ * @remarks
4
+ * The function uses the `path.join` method from the Node.js `path` module, and the `process.cwd` method from the Node.js `process` module.
5
+ * @param paths - The path segments to join to the current working directory path.
6
+ * @returns The resulting path.
7
+ * @example ```ts
8
+ * console.log(cwdpath('src', 'index.ts'));
9
+ * //=> '{working_directory}/src/index.ts'
10
+ * ```
11
+ */
12
+ export declare function cwdpath(...paths: string[]): string;
13
+ //# sourceMappingURL=cwdpath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cwdpath.d.ts","sourceRoot":"","sources":["../../../src/lib/cwdpath.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAElD"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Deletes a directory and all of its contents.
3
+ * @remarks This function uses Node.js's `fs.promises.rm` method with the `recursive` and `force` options set to `true`.
4
+ * This means it will delete the directory and all of its contents, even if the directory is not empty.
5
+ * @param dirpath The path to the directory to delete.
6
+ * @returns A Promise that resolves when the directory has been deleted.
7
+ * @throws Will throw an error if the directory does not exist, or if there was a problem deleting the directory.
8
+ * @example ```ts
9
+ * deleteDirectory('/path/to/directory');
10
+ * ```
11
+ */
12
+ export declare function deleteDirectory(dirpath: string): Promise<void>;
13
+ //# sourceMappingURL=deleteDirectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteDirectory.d.ts","sourceRoot":"","sources":["../../../src/lib/deleteDirectory.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Deletes a directory safely if it exists.
3
+ * @remarks This function uses Node.js' `fs.promises.rm` method with the `recursive` and `force` options set to `true`.
4
+ * This means it will delete the directory and all its contents, even if the directory is not empty.
5
+ * @param dirpath The path of the directory to delete.
6
+ * @returns A promise that resolves to `void` when the directory has been deleted.
7
+ * @throws Will throw an error if the `fs.promises.rm` operation fails.
8
+ * @example ```ts
9
+ * deleteDirectorySafe('/path/to/directory');;
10
+ * //=> undefined
11
+ * ```
12
+ */
13
+ export declare function deleteDirectorySafe(dirpath: string): Promise<void>;
14
+ //# sourceMappingURL=deleteDirectorySafe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteDirectorySafe.d.ts","sourceRoot":"","sources":["../../../src/lib/deleteDirectorySafe.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAExE"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Deletes a directory synchronously in a safe manner. If the directory does not exist, it will simply return the directory path without throwing an error.
3
+ * @param dirpath The path of the directory to be deleted.
4
+ * @returns The path of the directory that was intended to be deleted.
5
+ * @throws Will throw an error if the operation fails for reasons other than the directory not existing.
6
+ * @example ```ts
7
+ * deleteDirectorySafeSync('/path/to/directory');;
8
+ * //=> undefined
9
+ * ```
10
+ */
11
+ export declare function deleteDirectorySafeSync(dirpath: string): string;
12
+ //# sourceMappingURL=deleteDirectorySafeSync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteDirectorySafeSync.d.ts","sourceRoot":"","sources":["../../../src/lib/deleteDirectorySafeSync.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAI/D"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Deletes a directory synchronously.
3
+ * @remarks This function uses Node.js's `fs.rmSync` method with the options `{ recursive: true, force: true }`.
4
+ * @param dirpath The path of the directory to delete.
5
+ * @returns The path of the deleted directory.
6
+ * @throws Will throw an error if the directory does not exist or if the process lacks permissions to delete it.
7
+ * @example ```ts
8
+ * deleteDirectorySync('/path/to/directory');;
9
+ * //=> undefined
10
+ * ```
11
+ */
12
+ export declare function deleteDirectorySync(dirpath: string): string;
13
+ //# sourceMappingURL=deleteDirectorySync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteDirectorySync.d.ts","sourceRoot":"","sources":["../../../src/lib/deleteDirectorySync.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG3D"}
@@ -0,0 +1,23 @@
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;
23
+ //# sourceMappingURL=ensureValidWindowsPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureValidWindowsPath.d.ts","sourceRoot":"","sources":["../../../src/lib/ensureValidWindowsPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAA;AAEvF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAkCtG"}
@@ -0,0 +1,2 @@
1
+ export declare function getDiskDrivesWindows(): string[];
2
+ //# sourceMappingURL=getDiskDrivesWindows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDiskDrivesWindows.d.ts","sourceRoot":"","sources":["../../../src/lib/getDiskDrivesWindows.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAQ/C"}
@@ -0,0 +1,2 @@
1
+ export declare function getDownloadsDirectory(): string;
2
+ //# sourceMappingURL=getDownloadsDirectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDownloadsDirectory.d.ts","sourceRoot":"","sources":["../../../src/lib/getDownloadsDirectory.ts"],"names":[],"mappings":"AAGA,wBAAgB,qBAAqB,WAEpC"}
@@ -0,0 +1,2 @@
1
+ export declare function getHomeDirectory(): string;
2
+ //# sourceMappingURL=getHomeDirectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getHomeDirectory.d.ts","sourceRoot":"","sources":["../../../src/lib/getHomeDirectory.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC"}
@@ -0,0 +1,2 @@
1
+ export declare function getLastMofifiedFileIn(dirpath: string): Promise<string>;
2
+ //# sourceMappingURL=getLastMofifiedFileIn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLastMofifiedFileIn.d.ts","sourceRoot":"","sources":["../../../src/lib/getLastMofifiedFileIn.ts"],"names":[],"mappings":"AAGA,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAW5E"}
@@ -0,0 +1,2 @@
1
+ export declare function getRootDir(): string;
2
+ //# sourceMappingURL=getRootDir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRootDir.d.ts","sourceRoot":"","sources":["../../../src/lib/getRootDir.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,WAEzB"}
@@ -0,0 +1,2 @@
1
+ export declare function isWindows(): boolean;
2
+ //# sourceMappingURL=isWindows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isWindows.d.ts","sourceRoot":"","sources":["../../../src/lib/isWindows.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,YAExB"}
@@ -0,0 +1,23 @@
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;
23
+ //# sourceMappingURL=normalizeFileExtension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeFileExtension.d.ts","sourceRoot":"","sources":["../../../src/lib/normalizeFileExtension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO1D"}
@@ -0,0 +1,13 @@
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>;
13
+ //# sourceMappingURL=readJsonFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readJsonFile.d.ts","sourceRoot":"","sources":["../../../src/lib/readJsonFile.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAElE"}
@@ -0,0 +1,13 @@
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;
13
+ //# sourceMappingURL=readJsonFileSync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readJsonFileSync.d.ts","sourceRoot":"","sources":["../../../src/lib/readJsonFileSync.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAEvD"}
@@ -0,0 +1,2 @@
1
+ export declare function readPackageJson(projectRoot?: string): Record<string, any> | undefined;
2
+ //# sourceMappingURL=readPackageJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readPackageJson.d.ts","sourceRoot":"","sources":["../../../src/lib/readPackageJson.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,WAAW,SAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAI5F"}
@@ -0,0 +1,2 @@
1
+ export declare function removeIllegalFilenameCharacters(string: string): string;
2
+ //# sourceMappingURL=removeIllegalFilenameCharacters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeIllegalFilenameCharacters.d.ts","sourceRoot":"","sources":["../../../src/lib/removeIllegalFilenameCharacters.ts"],"names":[],"mappings":"AAAA,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,UAE7D"}
@@ -0,0 +1,11 @@
1
+ export interface IEnsureValidWindowsPathOptions {
2
+ /**
3
+ * On most versions of windows, the max allowed length of paths has been raised.
4
+ */
5
+ extendedMaxLength?: boolean;
6
+ /**
7
+ * Throw if not valid, otherwise return false.
8
+ */
9
+ assert?: boolean;
10
+ }
11
+ //# sourceMappingURL=IEnsureValidWindowsPathOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEnsureValidWindowsPathOptions.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/IEnsureValidWindowsPathOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB"}
@@ -0,0 +1,2 @@
1
+ export declare function unzipFile(filepath: string, outdir: string): Promise<void>;
2
+ //# sourceMappingURL=unzipFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unzipFile.d.ts","sourceRoot":"","sources":["../../../src/lib/unzipFile.ts"],"names":[],"mappings":"AAEA,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAE/D"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @param source Either a directory containing zip files or an array of zip file paths.
3
+ */
4
+ export declare function unzipMergeFiles(source: string | string[], target: string): Promise<void>;
5
+ //# sourceMappingURL=unzipMergeFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unzipMergeFiles.d.ts","sourceRoot":"","sources":["../../../src/lib/unzipMergeFiles.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,iBAY9E"}
@@ -0,0 +1,2 @@
1
+ export declare function wipeDirectorySafe(dirpath: string): Promise<void>;
2
+ //# sourceMappingURL=wipeDirectorySafe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wipeDirectorySafe.d.ts","sourceRoot":"","sources":["../../../src/lib/wipeDirectorySafe.ts"],"names":[],"mappings":"AAGA,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,iBAGtD"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Writes a JSON file to the specified filepath. The data to be written is passed as an argument.
3
+ * If the 'pretty' argument is set to true, the JSON data will be formatted in a more human-readable way.
4
+ * @template T - The type of the data to be written to the file.
5
+ * @param filepath - The path to the file where the data should be written.
6
+ * @param data - The data to be written to the file.
7
+ * @param pretty - Optional. If set to true, formats the JSON data in a more human-readable way. Default is false.
8
+ * @returns A Promise that resolves when the file has been successfully written.
9
+ * @example ```ts
10
+ * const data = { name: 'John', age: 30 };
11
+ * await writeJsonFile('./data.json', data, true);
12
+ * ```
13
+ */
14
+ export declare function writeJsonFile<T>(filepath: string, data: T, pretty?: boolean): Promise<void>;
15
+ //# sourceMappingURL=writeJsonFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeJsonFile.d.ts","sourceRoot":"","sources":["../../../src/lib/writeJsonFile.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/F"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Writes a JSON object to a file synchronously.
3
+ * @typeParam T - The type of the JSON object.
4
+ * @param filepath - The path of the file where the JSON object will be written.
5
+ * @param data - The JSON object that will be written to the file.
6
+ * @param pretty - If true, the JSON object will be formatted with indentation and line breaks. Default is false.
7
+ * @throws If the file cannot be written.
8
+ * @example ```ts
9
+ * const data = { name: 'John', age: 30 };
10
+ * writeJsonFileSync('./data.json', data, true);
11
+ * ```
12
+ */
13
+ export declare function writeJsonFileSync<T>(filepath: string, data: T, pretty?: boolean): void;
14
+ //# sourceMappingURL=writeJsonFileSync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeJsonFileSync.d.ts","sourceRoot":"","sources":["../../../src/lib/writeJsonFileSync.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,UAAQ,GAAG,IAAI,CAEpF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemoje/fs",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Tools for working with the local filesystem in nodejs.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -8,42 +8,9 @@
8
8
  "scripts": {
9
9
  "lint": "eslint \"*/**/*.{ts,js,json}\" --fix",
10
10
  "test": "jest --preset ts-jest",
11
- "rollup": "rollup --config ./rollup.config.js --bundleConfigAsCjs",
12
- "build": "npm run lint && rimraf dist && npm run rollup",
13
- "docsmd": "rimraf docs/md && typedoc --out docs/md/ src/index.ts --readme none --plugin typedoc-plugin-markdown --theme markdown --entryDocument index.md --publicPath /docs/md/",
14
- "docshtml": "rimraf docs/html && typedoc --out docs/html --entryPoints src/index.ts",
15
- "docs": "npm run docsmd && npm run docshtml",
16
- "viewdocs": "start docs/html/index.html",
17
- "prepub": "npm run build && npm run test && npm run docs"
18
- },
19
- "devDependencies": {
20
- "@rollup/plugin-commonjs": "^25.0.3",
21
- "@rollup/plugin-node-resolve": "^15.1.0",
22
- "@types/camel-case": "^1.2.1",
23
- "@types/commander": "^2.12.2",
24
- "@types/eslint-plugin-prettier": "^3.1.0",
25
- "@types/extract-zip": "^2.0.1",
26
- "@types/jest": "^29.5.3",
27
- "@types/node": "^20.4.8",
28
- "@types/rimraf": "^4.0.5",
29
- "@types/rollup": "^0.54.0",
30
- "@typescript-eslint/eslint-plugin": "^6.3.0",
31
- "@typescript-eslint/parser": "^6.3.0",
32
- "camel-case": "^4.1.2",
33
- "eslint": "^8.46.0",
34
- "eslint-config-prettier": "^9.0.0",
35
- "eslint-plugin-prettier": "^5.0.0",
36
- "jest": "^29.6.2",
37
- "jest-environment-node": "^29.6.2",
38
- "prettier": "^3.0.1",
39
- "rimraf": "^5.0.1",
40
- "rollup": "^3.27.2",
41
- "rollup-plugin-typescript2": "^0.35.0",
42
- "ts-jest": "^29.1.1",
43
- "ts-node": "^10.9.1",
44
- "tslib": "^2.6.1",
45
- "typedoc-plugin-markdown": "^3.15.4",
46
- "typescript": "^5.1.6"
11
+ "build": "rimraf dist && rollup --config ./rollup.config.js --bundleConfigAsCjs",
12
+ "docs": "rimraf ../../docs/fs && typedoc --out ../../docs/fs --entryPoints src/index.ts",
13
+ "prepub": "npm run lint && npm run build && npm run test && npm run docs"
47
14
  },
48
15
  "author": {
49
16
  "name": "Benjamin Møller Jensen",
@@ -53,7 +20,8 @@
53
20
  "license": "MIT",
54
21
  "keywords": [],
55
22
  "dependencies": {
56
- "@bemoje/string": "latest"
23
+ "@bemoje/string": "latest",
24
+ "extract-zip": "^2.0.1"
57
25
  },
58
26
  "repository": {
59
27
  "type": "git",
@@ -66,5 +34,8 @@
66
34
  "bugs": {
67
35
  "url": "https://github.com/bemoje/tsmono/issues"
68
36
  },
69
- "homepage": "https://github.com/bemoje/tsmono"
37
+ "homepage": "https://github.com/bemoje/tsmono",
38
+ "devDependencies": {
39
+ "@types/extract-zip": "^2.0.1"
40
+ }
70
41
  }
package/project.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "fs",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "pkg/fs/src",
5
+ "projectType": "library",
6
+ "targets": {},
7
+ "tags": []
8
+ }