@bemoje/fs 0.2.11 → 0.3.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/LICENSE +21 -0
- package/README.md +2 -2
- package/cjs/index.d.ts +80 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +83 -0
- package/cjs/index.js.map +1 -0
- package/cjs/lib/appendFile.d.ts +10 -0
- package/cjs/lib/appendFile.d.ts.map +1 -0
- package/cjs/lib/appendFile.js +23 -0
- package/cjs/lib/appendFile.js.map +1 -0
- package/cjs/lib/appendFileLine.d.ts +7 -0
- package/cjs/lib/appendFileLine.d.ts.map +1 -0
- package/cjs/lib/appendFileLine.js +16 -0
- package/cjs/lib/appendFileLine.js.map +1 -0
- package/cjs/lib/appendFileLineSync.d.ts +7 -0
- package/cjs/lib/appendFileLineSync.d.ts.map +1 -0
- package/cjs/lib/appendFileLineSync.js +16 -0
- package/cjs/lib/appendFileLineSync.js.map +1 -0
- package/cjs/lib/appendFileSync.d.ts +10 -0
- package/cjs/lib/appendFileSync.d.ts.map +1 -0
- package/cjs/lib/appendFileSync.js +23 -0
- package/cjs/lib/appendFileSync.js.map +1 -0
- package/{src → cjs}/lib/createDirectory.d.ts +1 -5
- package/cjs/lib/createDirectory.d.ts.map +1 -0
- package/cjs/lib/createDirectory.js +18 -0
- package/cjs/lib/createDirectory.js.map +1 -0
- package/{src → cjs}/lib/createDirectorySync.d.ts +1 -3
- package/cjs/lib/createDirectorySync.d.ts.map +1 -0
- package/{src → cjs}/lib/createDirectorySync.js +2 -5
- package/cjs/lib/createDirectorySync.js.map +1 -0
- package/cjs/lib/emptyDirectory.d.ts +17 -0
- package/cjs/lib/emptyDirectory.d.ts.map +1 -0
- package/cjs/lib/emptyDirectory.js +26 -0
- package/cjs/lib/emptyDirectory.js.map +1 -0
- package/cjs/lib/emptyDirectorySync.d.ts +17 -0
- package/cjs/lib/emptyDirectorySync.d.ts.map +1 -0
- package/cjs/lib/emptyDirectorySync.js +29 -0
- package/cjs/lib/emptyDirectorySync.js.map +1 -0
- package/{src → cjs}/lib/getJsonIndentation.d.ts +1 -0
- package/cjs/lib/getJsonIndentation.d.ts.map +1 -0
- package/{src → cjs}/lib/getJsonIndentation.js +2 -2
- package/{src → cjs}/lib/getJsonIndentation.js.map +1 -1
- package/{src → cjs}/lib/getLastMofifiedFileIn.d.ts +1 -0
- package/cjs/lib/getLastMofifiedFileIn.d.ts.map +1 -0
- package/cjs/lib/getLastMofifiedFileIn.js +20 -0
- package/cjs/lib/getLastMofifiedFileIn.js.map +1 -0
- package/cjs/lib/promptUserEditInTextEditor.d.ts +10 -0
- package/cjs/lib/promptUserEditInTextEditor.d.ts.map +1 -0
- package/cjs/lib/promptUserEditInTextEditor.js +29 -0
- package/cjs/lib/promptUserEditInTextEditor.js.map +1 -0
- package/cjs/lib/promptUserEditInTextEditorSync.d.ts +10 -0
- package/cjs/lib/promptUserEditInTextEditorSync.d.ts.map +1 -0
- package/cjs/lib/promptUserEditInTextEditorSync.js +27 -0
- package/cjs/lib/promptUserEditInTextEditorSync.js.map +1 -0
- package/cjs/lib/promptUserEditJsonInTextEditor.d.ts +13 -0
- package/cjs/lib/promptUserEditJsonInTextEditor.d.ts.map +1 -0
- package/cjs/lib/promptUserEditJsonInTextEditor.js +25 -0
- package/cjs/lib/promptUserEditJsonInTextEditor.js.map +1 -0
- package/cjs/lib/promptUserEditJsonInTextEditorSync.d.ts +13 -0
- package/cjs/lib/promptUserEditJsonInTextEditorSync.d.ts.map +1 -0
- package/cjs/lib/promptUserEditJsonInTextEditorSync.js +25 -0
- package/cjs/lib/promptUserEditJsonInTextEditorSync.js.map +1 -0
- package/cjs/lib/readDirectoryDirents.d.ts +11 -0
- package/cjs/lib/readDirectoryDirents.d.ts.map +1 -0
- package/cjs/lib/readDirectoryDirents.js +17 -0
- package/cjs/lib/readDirectoryDirents.js.map +1 -0
- package/cjs/lib/readDirectoryDirentsPaths.d.ts +14 -0
- package/cjs/lib/readDirectoryDirentsPaths.d.ts.map +1 -0
- package/cjs/lib/readDirectoryDirentsPaths.js +27 -0
- package/cjs/lib/readDirectoryDirentsPaths.js.map +1 -0
- package/cjs/lib/readDirectoryDirentsPathsSafe.d.ts +15 -0
- package/cjs/lib/readDirectoryDirentsPathsSafe.d.ts.map +1 -0
- package/cjs/lib/readDirectoryDirentsPathsSafe.js +22 -0
- package/cjs/lib/readDirectoryDirentsPathsSafe.js.map +1 -0
- package/cjs/lib/readDirectoryDirentsPathsSafeSync.d.ts +15 -0
- package/cjs/lib/readDirectoryDirentsPathsSafeSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryDirentsPathsSafeSync.js +22 -0
- package/cjs/lib/readDirectoryDirentsPathsSafeSync.js.map +1 -0
- package/cjs/lib/readDirectoryDirentsPathsSync.d.ts +14 -0
- package/cjs/lib/readDirectoryDirentsPathsSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryDirentsPathsSync.js +27 -0
- package/cjs/lib/readDirectoryDirentsPathsSync.js.map +1 -0
- package/cjs/lib/readDirectoryDirentsSafe.d.ts +12 -0
- package/cjs/lib/readDirectoryDirentsSafe.d.ts.map +1 -0
- package/cjs/lib/readDirectoryDirentsSafe.js +20 -0
- package/cjs/lib/readDirectoryDirentsSafe.js.map +1 -0
- package/cjs/lib/readDirectoryDirentsSafeSync.d.ts +12 -0
- package/cjs/lib/readDirectoryDirentsSafeSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryDirentsSafeSync.js +20 -0
- package/cjs/lib/readDirectoryDirentsSafeSync.js.map +1 -0
- package/cjs/lib/readDirectoryDirentsSync.d.ts +11 -0
- package/cjs/lib/readDirectoryDirentsSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryDirentsSync.js +17 -0
- package/cjs/lib/readDirectoryDirentsSync.js.map +1 -0
- package/cjs/lib/readDirectoryNames.d.ts +7 -0
- package/cjs/lib/readDirectoryNames.d.ts.map +1 -0
- package/cjs/lib/readDirectoryNames.js +15 -0
- package/cjs/lib/readDirectoryNames.js.map +1 -0
- package/cjs/lib/readDirectoryNamesPaths.d.ts +11 -0
- package/cjs/lib/readDirectoryNamesPaths.d.ts.map +1 -0
- package/cjs/lib/readDirectoryNamesPaths.js +24 -0
- package/cjs/lib/readDirectoryNamesPaths.js.map +1 -0
- package/cjs/lib/readDirectoryNamesPathsSafe.d.ts +12 -0
- package/cjs/lib/readDirectoryNamesPathsSafe.d.ts.map +1 -0
- package/cjs/lib/readDirectoryNamesPathsSafe.js +20 -0
- package/cjs/lib/readDirectoryNamesPathsSafe.js.map +1 -0
- package/cjs/lib/readDirectoryNamesPathsSafeSync.d.ts +12 -0
- package/cjs/lib/readDirectoryNamesPathsSafeSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryNamesPathsSafeSync.js +20 -0
- package/cjs/lib/readDirectoryNamesPathsSafeSync.js.map +1 -0
- package/cjs/lib/readDirectoryNamesPathsSync.d.ts +11 -0
- package/cjs/lib/readDirectoryNamesPathsSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryNamesPathsSync.js +24 -0
- package/cjs/lib/readDirectoryNamesPathsSync.js.map +1 -0
- package/cjs/lib/readDirectoryNamesSafe.d.ts +8 -0
- package/cjs/lib/readDirectoryNamesSafe.d.ts.map +1 -0
- package/cjs/lib/readDirectoryNamesSafe.js +18 -0
- package/cjs/lib/readDirectoryNamesSafe.js.map +1 -0
- package/cjs/lib/readDirectoryNamesSafeSync.d.ts +8 -0
- package/cjs/lib/readDirectoryNamesSafeSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryNamesSafeSync.js +18 -0
- package/cjs/lib/readDirectoryNamesSafeSync.js.map +1 -0
- package/cjs/lib/readDirectoryNamesSync.d.ts +7 -0
- package/cjs/lib/readDirectoryNamesSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryNamesSync.js +15 -0
- package/cjs/lib/readDirectoryNamesSync.js.map +1 -0
- package/cjs/lib/readDirectoryPaths.d.ts +7 -0
- package/cjs/lib/readDirectoryPaths.d.ts.map +1 -0
- package/cjs/lib/readDirectoryPaths.js +18 -0
- package/cjs/lib/readDirectoryPaths.js.map +1 -0
- package/cjs/lib/readDirectoryPathsSafe.d.ts +8 -0
- package/cjs/lib/readDirectoryPathsSafe.d.ts.map +1 -0
- package/cjs/lib/readDirectoryPathsSafe.js +19 -0
- package/cjs/lib/readDirectoryPathsSafe.js.map +1 -0
- package/cjs/lib/readDirectoryPathsSafeSync.d.ts +8 -0
- package/cjs/lib/readDirectoryPathsSafeSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryPathsSafeSync.js +19 -0
- package/cjs/lib/readDirectoryPathsSafeSync.js.map +1 -0
- package/cjs/lib/readDirectoryPathsSync.d.ts +7 -0
- package/cjs/lib/readDirectoryPathsSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryPathsSync.js +18 -0
- package/cjs/lib/readDirectoryPathsSync.js.map +1 -0
- package/cjs/lib/readDirectoryStats.d.ts +13 -0
- package/cjs/lib/readDirectoryStats.d.ts.map +1 -0
- package/cjs/lib/readDirectoryStats.js +33 -0
- package/cjs/lib/readDirectoryStats.js.map +1 -0
- package/cjs/lib/readDirectoryStatsSafe.d.ts +14 -0
- package/cjs/lib/readDirectoryStatsSafe.d.ts.map +1 -0
- package/cjs/lib/readDirectoryStatsSafe.js +20 -0
- package/cjs/lib/readDirectoryStatsSafe.js.map +1 -0
- package/cjs/lib/readDirectoryStatsSafeSync.d.ts +14 -0
- package/cjs/lib/readDirectoryStatsSafeSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryStatsSafeSync.js +20 -0
- package/cjs/lib/readDirectoryStatsSafeSync.js.map +1 -0
- package/cjs/lib/readDirectoryStatsSync.d.ts +13 -0
- package/cjs/lib/readDirectoryStatsSync.d.ts.map +1 -0
- package/cjs/lib/readDirectoryStatsSync.js +32 -0
- package/cjs/lib/readDirectoryStatsSync.js.map +1 -0
- package/cjs/lib/readFile.d.ts +22 -0
- package/cjs/lib/readFile.d.ts.map +1 -0
- package/cjs/lib/readFile.js +21 -0
- package/cjs/lib/readFile.js.map +1 -0
- package/cjs/lib/readFileBuffer.d.ts +20 -0
- package/cjs/lib/readFileBuffer.d.ts.map +1 -0
- package/cjs/lib/readFileBuffer.js +20 -0
- package/cjs/lib/readFileBuffer.js.map +1 -0
- package/cjs/lib/readFileBufferSafe.d.ts +12 -0
- package/cjs/lib/readFileBufferSafe.d.ts.map +1 -0
- package/cjs/lib/readFileBufferSafe.js +24 -0
- package/cjs/lib/readFileBufferSafe.js.map +1 -0
- package/cjs/lib/readFileBufferSafeSync.d.ts +12 -0
- package/cjs/lib/readFileBufferSafeSync.d.ts.map +1 -0
- package/cjs/lib/readFileBufferSafeSync.js +24 -0
- package/cjs/lib/readFileBufferSafeSync.js.map +1 -0
- package/cjs/lib/readFileBufferSync.d.ts +10 -0
- package/cjs/lib/readFileBufferSync.d.ts.map +1 -0
- package/cjs/lib/readFileBufferSync.js +17 -0
- package/cjs/lib/readFileBufferSync.js.map +1 -0
- package/cjs/lib/readFileSafe.d.ts +14 -0
- package/cjs/lib/readFileSafe.d.ts.map +1 -0
- package/cjs/lib/readFileSafe.js +26 -0
- package/cjs/lib/readFileSafe.js.map +1 -0
- package/cjs/lib/readFileSafeSync.d.ts +14 -0
- package/cjs/lib/readFileSafeSync.d.ts.map +1 -0
- package/cjs/lib/readFileSafeSync.js +26 -0
- package/cjs/lib/readFileSafeSync.js.map +1 -0
- package/cjs/lib/readFileSync.d.ts +11 -0
- package/cjs/lib/readFileSync.d.ts.map +1 -0
- package/cjs/lib/readFileSync.js +18 -0
- package/cjs/lib/readFileSync.js.map +1 -0
- package/cjs/lib/readJsonFile.d.ts +2 -0
- package/cjs/lib/readJsonFile.d.ts.map +1 -0
- package/cjs/lib/readJsonFile.js +6 -0
- package/cjs/lib/readJsonFile.js.map +1 -0
- package/cjs/lib/readJsonFileSafe.d.ts +10 -0
- package/cjs/lib/readJsonFileSafe.d.ts.map +1 -0
- package/cjs/lib/readJsonFileSafe.js +22 -0
- package/cjs/lib/readJsonFileSafe.js.map +1 -0
- package/cjs/lib/readJsonFileSafeSync.d.ts +10 -0
- package/cjs/lib/readJsonFileSafeSync.d.ts.map +1 -0
- package/cjs/lib/readJsonFileSafeSync.js +22 -0
- package/cjs/lib/readJsonFileSafeSync.js.map +1 -0
- package/cjs/lib/readJsonFileSync.d.ts +2 -0
- package/cjs/lib/readJsonFileSync.d.ts.map +1 -0
- package/cjs/lib/readJsonFileSync.js +6 -0
- package/cjs/lib/readJsonFileSync.js.map +1 -0
- package/cjs/lib/removeDirectory.d.ts +2 -0
- package/cjs/lib/removeDirectory.d.ts.map +1 -0
- package/cjs/lib/removeDirectory.js +6 -0
- package/cjs/lib/removeDirectory.js.map +1 -0
- package/cjs/lib/removeDirectorySync.d.ts +2 -0
- package/cjs/lib/removeDirectorySync.d.ts.map +1 -0
- package/cjs/lib/removeDirectorySync.js +6 -0
- package/cjs/lib/removeDirectorySync.js.map +1 -0
- package/cjs/lib/removeFile.d.ts +2 -0
- package/cjs/lib/removeFile.d.ts.map +1 -0
- package/cjs/lib/removeFile.js +6 -0
- package/cjs/lib/removeFile.js.map +1 -0
- package/cjs/lib/removeFileSync.d.ts +2 -0
- package/cjs/lib/removeFileSync.d.ts.map +1 -0
- package/cjs/lib/removeFileSync.js +6 -0
- package/cjs/lib/removeFileSync.js.map +1 -0
- package/{src → cjs}/lib/tempFile.d.ts +3 -2
- package/cjs/lib/tempFile.d.ts.map +1 -0
- package/cjs/lib/tempFile.js +27 -0
- package/cjs/lib/tempFile.js.map +1 -0
- package/cjs/lib/tempFileSync.d.ts +7 -0
- package/cjs/lib/tempFileSync.d.ts.map +1 -0
- package/cjs/lib/tempFileSync.js +27 -0
- package/cjs/lib/tempFileSync.js.map +1 -0
- package/cjs/lib/types/IGetUserInputFromEditorOptions.d.ts +16 -0
- package/cjs/lib/types/IGetUserInputFromEditorOptions.d.ts.map +1 -0
- package/{src/lib/types/IEnsureValidWindowsPathOptions.js → cjs/lib/types/IGetUserInputFromEditorOptions.js} +1 -1
- package/cjs/lib/types/IGetUserInputFromEditorOptions.js.map +1 -0
- package/cjs/lib/types/IJFReadOptions.d.ts +2 -0
- package/cjs/lib/types/IJFReadOptions.d.ts.map +1 -0
- package/cjs/lib/types/IJFReadOptions.js +3 -0
- package/cjs/lib/types/IJFReadOptions.js.map +1 -0
- package/cjs/lib/types/IJFWriteOptions.d.ts +2 -0
- package/cjs/lib/types/IJFWriteOptions.d.ts.map +1 -0
- package/cjs/lib/types/IJFWriteOptions.js +3 -0
- package/cjs/lib/types/IJFWriteOptions.js.map +1 -0
- package/cjs/lib/types/IJsonOutputOptions.d.ts +2 -0
- package/cjs/lib/types/IJsonOutputOptions.d.ts.map +1 -0
- package/cjs/lib/types/IJsonOutputOptions.js +3 -0
- package/cjs/lib/types/IJsonOutputOptions.js.map +1 -0
- package/{src → cjs}/lib/types/ILogFileData.d.ts +1 -0
- package/cjs/lib/types/ILogFileData.d.ts.map +1 -0
- package/cjs/lib/types/IReadJsonFileOptions.d.ts +2 -0
- package/cjs/lib/types/IReadJsonFileOptions.d.ts.map +1 -0
- package/cjs/lib/types/IReadJsonFileOptions.js +3 -0
- package/cjs/lib/types/IReadJsonFileOptions.js.map +1 -0
- package/cjs/lib/types/JsonReplacerReviver.d.ts +2 -0
- package/cjs/lib/types/JsonReplacerReviver.d.ts.map +1 -0
- package/cjs/lib/types/JsonReplacerReviver.js +3 -0
- package/cjs/lib/types/JsonReplacerReviver.js.map +1 -0
- package/cjs/lib/updateFile.d.ts +11 -0
- package/cjs/lib/updateFile.d.ts.map +1 -0
- package/cjs/lib/updateFile.js +20 -0
- package/cjs/lib/updateFile.js.map +1 -0
- package/cjs/lib/updateFileSafe.d.ts +13 -0
- package/cjs/lib/updateFileSafe.d.ts.map +1 -0
- package/cjs/lib/updateFileSafe.js +28 -0
- package/cjs/lib/updateFileSafe.js.map +1 -0
- package/cjs/lib/updateFileSafeSync.d.ts +13 -0
- package/cjs/lib/updateFileSafeSync.d.ts.map +1 -0
- package/cjs/lib/updateFileSafeSync.js +28 -0
- package/cjs/lib/updateFileSafeSync.js.map +1 -0
- package/cjs/lib/updateFileSync.d.ts +11 -0
- package/cjs/lib/updateFileSync.d.ts.map +1 -0
- package/cjs/lib/updateFileSync.js +20 -0
- package/cjs/lib/updateFileSync.js.map +1 -0
- package/cjs/lib/updateJsonFile.d.ts +15 -0
- package/cjs/lib/updateJsonFile.d.ts.map +1 -0
- package/cjs/lib/updateJsonFile.js +20 -0
- package/cjs/lib/updateJsonFile.js.map +1 -0
- package/cjs/lib/updateJsonFileSafe.d.ts +17 -0
- package/cjs/lib/updateJsonFileSafe.d.ts.map +1 -0
- package/cjs/lib/updateJsonFileSafe.js +28 -0
- package/cjs/lib/updateJsonFileSafe.js.map +1 -0
- package/cjs/lib/updateJsonFileSafeSync.d.ts +17 -0
- package/cjs/lib/updateJsonFileSafeSync.d.ts.map +1 -0
- package/cjs/lib/updateJsonFileSafeSync.js +28 -0
- package/cjs/lib/updateJsonFileSafeSync.js.map +1 -0
- package/cjs/lib/updateJsonFileSync.d.ts +15 -0
- package/cjs/lib/updateJsonFileSync.d.ts.map +1 -0
- package/cjs/lib/updateJsonFileSync.js +20 -0
- package/cjs/lib/updateJsonFileSync.js.map +1 -0
- package/cjs/lib/writeFile.d.ts +2 -0
- package/cjs/lib/writeFile.d.ts.map +1 -0
- package/cjs/lib/writeFile.js +6 -0
- package/cjs/lib/writeFile.js.map +1 -0
- package/cjs/lib/writeFileSafe.d.ts +2 -0
- package/cjs/lib/writeFileSafe.d.ts.map +1 -0
- package/cjs/lib/writeFileSafe.js +6 -0
- package/cjs/lib/writeFileSafe.js.map +1 -0
- package/cjs/lib/writeFileSafeSync.d.ts +2 -0
- package/cjs/lib/writeFileSafeSync.d.ts.map +1 -0
- package/cjs/lib/writeFileSafeSync.js +6 -0
- package/cjs/lib/writeFileSafeSync.js.map +1 -0
- package/cjs/lib/writeFileSync.d.ts +2 -0
- package/cjs/lib/writeFileSync.d.ts.map +1 -0
- package/cjs/lib/writeFileSync.js +6 -0
- package/cjs/lib/writeFileSync.js.map +1 -0
- package/cjs/lib/writeJsonFile.d.ts +2 -0
- package/cjs/lib/writeJsonFile.d.ts.map +1 -0
- package/cjs/lib/writeJsonFile.js +6 -0
- package/cjs/lib/writeJsonFile.js.map +1 -0
- package/cjs/lib/writeJsonFileSafe.d.ts +2 -0
- package/cjs/lib/writeJsonFileSafe.d.ts.map +1 -0
- package/cjs/lib/writeJsonFileSafe.js +6 -0
- package/cjs/lib/writeJsonFileSafe.js.map +1 -0
- package/cjs/lib/writeJsonFileSafeSync.d.ts +2 -0
- package/cjs/lib/writeJsonFileSafeSync.d.ts.map +1 -0
- package/cjs/lib/writeJsonFileSafeSync.js +6 -0
- package/cjs/lib/writeJsonFileSafeSync.js.map +1 -0
- package/cjs/lib/writeJsonFileSync.d.ts +2 -0
- package/cjs/lib/writeJsonFileSync.d.ts.map +1 -0
- package/cjs/lib/writeJsonFileSync.js +6 -0
- package/cjs/lib/writeJsonFileSync.js.map +1 -0
- package/package.json +11 -16
- package/src/index.d.ts +0 -35
- package/src/index.js +0 -39
- package/src/index.js.map +0 -1
- package/src/lib/AppData.d.ts +0 -10
- package/src/lib/AppData.js +0 -24
- package/src/lib/AppData.js.map +0 -1
- package/src/lib/JsonFile.d.ts +0 -78
- package/src/lib/JsonFile.js +0 -158
- package/src/lib/JsonFile.js.map +0 -1
- package/src/lib/LogFile.d.ts +0 -50
- package/src/lib/LogFile.js +0 -158
- package/src/lib/LogFile.js.map +0 -1
- package/src/lib/absoluteToRelativePath.d.ts +0 -13
- package/src/lib/absoluteToRelativePath.js +0 -25
- package/src/lib/absoluteToRelativePath.js.map +0 -1
- package/src/lib/appendLineToFile.d.ts +0 -11
- package/src/lib/appendLineToFile.js +0 -28
- package/src/lib/appendLineToFile.js.map +0 -1
- package/src/lib/cleanDirectorySync.d.ts +0 -16
- package/src/lib/cleanDirectorySync.js +0 -29
- package/src/lib/cleanDirectorySync.js.map +0 -1
- package/src/lib/createDirectory.js +0 -25
- package/src/lib/createDirectory.js.map +0 -1
- package/src/lib/createDirectorySync.js.map +0 -1
- package/src/lib/createFileExtensionFilter.d.ts +0 -13
- package/src/lib/createFileExtensionFilter.js +0 -32
- package/src/lib/createFileExtensionFilter.js.map +0 -1
- package/src/lib/cwdpath.d.ts +0 -12
- package/src/lib/cwdpath.js +0 -21
- package/src/lib/cwdpath.js.map +0 -1
- package/src/lib/deleteDirectory.d.ts +0 -12
- package/src/lib/deleteDirectory.js +0 -23
- package/src/lib/deleteDirectory.js.map +0 -1
- package/src/lib/deleteDirectorySafe.d.ts +0 -13
- package/src/lib/deleteDirectorySafe.js +0 -25
- package/src/lib/deleteDirectorySafe.js.map +0 -1
- package/src/lib/deleteDirectorySafeSync.d.ts +0 -11
- package/src/lib/deleteDirectorySafeSync.js +0 -23
- package/src/lib/deleteDirectorySafeSync.js.map +0 -1
- package/src/lib/deleteDirectorySync.d.ts +0 -12
- package/src/lib/deleteDirectorySync.js +0 -22
- package/src/lib/deleteDirectorySync.js.map +0 -1
- package/src/lib/ensureValidWindowsPath.d.ts +0 -22
- package/src/lib/ensureValidWindowsPath.js +0 -54
- package/src/lib/ensureValidWindowsPath.js.map +0 -1
- package/src/lib/getDiskDrivesWindows.d.ts +0 -1
- package/src/lib/getDiskDrivesWindows.js +0 -19
- package/src/lib/getDiskDrivesWindows.js.map +0 -1
- package/src/lib/getDownloadsDirectory.d.ts +0 -1
- package/src/lib/getDownloadsDirectory.js +0 -11
- package/src/lib/getDownloadsDirectory.js.map +0 -1
- package/src/lib/getHomeDirectory.d.ts +0 -1
- package/src/lib/getHomeDirectory.js +0 -13
- package/src/lib/getHomeDirectory.js.map +0 -1
- package/src/lib/getLastMofifiedFileIn.js +0 -22
- package/src/lib/getLastMofifiedFileIn.js.map +0 -1
- package/src/lib/getRootDir.d.ts +0 -1
- package/src/lib/getRootDir.js +0 -10
- package/src/lib/getRootDir.js.map +0 -1
- package/src/lib/normalizeFileExtension.d.ts +0 -22
- package/src/lib/normalizeFileExtension.js +0 -36
- package/src/lib/normalizeFileExtension.js.map +0 -1
- package/src/lib/readFileLastLines.d.ts +0 -7
- package/src/lib/readFileLastLines.js +0 -18
- package/src/lib/readFileLastLines.js.map +0 -1
- package/src/lib/readJsonFile.d.ts +0 -12
- package/src/lib/readJsonFile.js +0 -23
- package/src/lib/readJsonFile.js.map +0 -1
- package/src/lib/readJsonFileSync.d.ts +0 -12
- package/src/lib/readJsonFileSync.js +0 -21
- package/src/lib/readJsonFileSync.js.map +0 -1
- package/src/lib/readPackageJson.d.ts +0 -1
- package/src/lib/readPackageJson.js +0 -15
- package/src/lib/readPackageJson.js.map +0 -1
- package/src/lib/removeIllegalFilenameCharacters.d.ts +0 -1
- package/src/lib/removeIllegalFilenameCharacters.js +0 -8
- package/src/lib/removeIllegalFilenameCharacters.js.map +0 -1
- package/src/lib/tempFile.js +0 -26
- package/src/lib/tempFile.js.map +0 -1
- package/src/lib/types/IEnsureValidWindowsPathOptions.d.ts +0 -10
- package/src/lib/types/IEnsureValidWindowsPathOptions.js.map +0 -1
- package/src/lib/updateJsonFile.d.ts +0 -18
- package/src/lib/updateJsonFile.js +0 -44
- package/src/lib/updateJsonFile.js.map +0 -1
- package/src/lib/updateJsonFileSync.d.ts +0 -18
- package/src/lib/updateJsonFileSync.js +0 -42
- package/src/lib/updateJsonFileSync.js.map +0 -1
- package/src/lib/wipeDirectorySafe.d.ts +0 -1
- package/src/lib/wipeDirectorySafe.js +0 -14
- package/src/lib/wipeDirectorySafe.js.map +0 -1
- package/src/lib/writeJsonFile.d.ts +0 -14
- package/src/lib/writeJsonFile.js +0 -25
- package/src/lib/writeJsonFile.js.map +0 -1
- package/src/lib/writeJsonFileSync.d.ts +0 -13
- package/src/lib/writeJsonFileSync.js +0 -22
- package/src/lib/writeJsonFileSync.js.map +0 -1
- /package/{src → cjs}/lib/types/ILogFileData.js +0 -0
- /package/{src → cjs}/lib/types/ILogFileData.js.map +0 -0
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteDirectorySync = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
/**
|
|
7
|
-
* Deletes a directory synchronously.
|
|
8
|
-
* @remarks This function uses Node.js's `fs.rmSync` method with the options `{ recursive: true, force: true }`.
|
|
9
|
-
* @param dirpath The path of the directory to delete.
|
|
10
|
-
* @returns The path of the deleted directory.
|
|
11
|
-
* @throws Will throw an error if the directory does not exist or if the process lacks permissions to delete it.
|
|
12
|
-
* @example ```ts
|
|
13
|
-
* deleteDirectorySync('/path/to/directory');;
|
|
14
|
-
* //=> undefined
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
function deleteDirectorySync(dirpath) {
|
|
18
|
-
fs_1.default.rmSync(dirpath, { recursive: true, force: true });
|
|
19
|
-
return dirpath;
|
|
20
|
-
}
|
|
21
|
-
exports.deleteDirectorySync = deleteDirectorySync;
|
|
22
|
-
//# sourceMappingURL=deleteDirectorySync.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deleteDirectorySync.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/deleteDirectorySync.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AAEnB;;;;;;;;;;GAUG;AACH,SAAgB,mBAAmB,CAAC,OAAe;IACjD,YAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,OAAO,OAAO,CAAA;AAChB,CAAC;AAHD,kDAGC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getDiskDrivesWindows(): string[];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDiskDrivesWindows = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const os_1 = require("@bemoje/os");
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
7
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
-
function getDiskDrivesWindows() {
|
|
9
|
-
if (!(0, os_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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDiskDrivesWindows.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/getDiskDrivesWindows.ts"],"names":[],"mappings":";;;;AAAA,mCAAsC;AACtC,iDAAwC;AACxC,wDAAuB;AAEvB,SAAgB,oBAAoB;IAClC,IAAI,CAAC,IAAA,cAAS,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getDownloadsDirectory(): string;
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getHomeDirectory(): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/src/lib/getRootDir.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getRootDir(): string;
|
package/src/lib/getRootDir.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,7 +0,0 @@
|
|
|
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>;
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,12 +0,0 @@
|
|
|
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>;
|
package/src/lib/readJsonFile.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,12 +0,0 @@
|
|
|
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;
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function readPackageJson(projectRoot?: string): Record<string, any> | undefined;
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function removeIllegalFilenameCharacters(string: string): string;
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/src/lib/tempFile.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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
|
package/src/lib/tempFile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IEnsureValidWindowsPathOptions.js","sourceRoot":"","sources":["../../../../../../packages/fs/src/lib/types/IEnsureValidWindowsPathOptions.ts"],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Updates a JSON file asynchronously based on a provided update function.
|
|
3
|
-
* The update function takes the current JSON object as a parameter and should return the updated JSON object.
|
|
4
|
-
* If the update function returns a falsy value, the JSON file will not be written to.
|
|
5
|
-
* The indentation of the original JSON file is preserved.
|
|
6
|
-
*
|
|
7
|
-
* @param filepath - The path to the JSON file to update.
|
|
8
|
-
* @param update - The function to update the JSON object. Takes the current JSON object as a parameter and should return the updated JSON object.
|
|
9
|
-
* @throws If the file cannot be read or written to.
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* await updateJsonFileSync('./package.json', (json) => {
|
|
13
|
-
* json.version = '1.0.1';
|
|
14
|
-
* return json;
|
|
15
|
-
* });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function updateJsonFile(filepath: string, update: (o: Record<string, unknown>) => Record<string, unknown> | Promise<Record<string, unknown>>, defaultJson?: string): Promise<void>;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateJsonFile = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const getJsonIndentation_1 = require("./getJsonIndentation");
|
|
7
|
-
const writeJsonFile_1 = require("./writeJsonFile");
|
|
8
|
-
/**
|
|
9
|
-
* Updates a JSON file asynchronously based on a provided update function.
|
|
10
|
-
* The update function takes the current JSON object as a parameter and should return the updated JSON object.
|
|
11
|
-
* If the update function returns a falsy value, the JSON file will not be written to.
|
|
12
|
-
* The indentation of the original JSON file is preserved.
|
|
13
|
-
*
|
|
14
|
-
* @param filepath - The path to the JSON file to update.
|
|
15
|
-
* @param update - The function to update the JSON object. Takes the current JSON object as a parameter and should return the updated JSON object.
|
|
16
|
-
* @throws If the file cannot be read or written to.
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* await updateJsonFileSync('./package.json', (json) => {
|
|
20
|
-
* json.version = '1.0.1';
|
|
21
|
-
* return json;
|
|
22
|
-
* });
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
function updateJsonFile(filepath, update, defaultJson) {
|
|
26
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
let json;
|
|
28
|
-
try {
|
|
29
|
-
json = yield fs_1.default.promises.readFile(filepath, 'utf8');
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (!defaultJson)
|
|
33
|
-
throw error;
|
|
34
|
-
json = defaultJson;
|
|
35
|
-
}
|
|
36
|
-
const result = yield update(JSON.parse(json));
|
|
37
|
-
if (!result)
|
|
38
|
-
return;
|
|
39
|
-
const indents = (0, getJsonIndentation_1.getJsonIndentation)(json);
|
|
40
|
-
yield (0, writeJsonFile_1.writeJsonFile)(filepath, result, !!indents, indents);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
exports.updateJsonFile = updateJsonFile;
|
|
44
|
-
//# sourceMappingURL=updateJsonFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"updateJsonFile.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/updateJsonFile.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AACnB,6DAAyD;AACzD,mDAA+C;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAsB,cAAc,CAClC,QAAgB,EAChB,MAAkG,EAClG,WAAoB;;QAEpB,IAAI,IAAY,CAAA;QAChB,IAAI;YACF,IAAI,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;SACpD;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,WAAW;gBAAE,MAAM,KAAK,CAAA;YAC7B,IAAI,GAAG,WAAW,CAAA;SACnB;QACD,MAAM,MAAM,GAA4B,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QACtE,IAAI,CAAC,MAAM;YAAE,OAAM;QACnB,MAAM,OAAO,GAAG,IAAA,uCAAkB,EAAC,IAAI,CAAC,CAAA;QACxC,MAAM,IAAA,6BAAa,EAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC3D,CAAC;CAAA;AAhBD,wCAgBC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Updates a JSON file synchronously based on a provided update function.
|
|
3
|
-
* The update function takes the current JSON object as a parameter and should return the updated JSON object.
|
|
4
|
-
* If the update function returns a falsy value, the JSON file will not be written to.
|
|
5
|
-
* The indentation of the original JSON file is preserved.
|
|
6
|
-
*
|
|
7
|
-
* @param filepath - The path to the JSON file to update.
|
|
8
|
-
* @param update - The function to update the JSON object. Takes the current JSON object as a parameter and should return the updated JSON object.
|
|
9
|
-
* @throws If the file cannot be read or written to.
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* updateJsonFileSync('./package.json', (json) => {
|
|
13
|
-
* json.version = '1.0.1';
|
|
14
|
-
* return json;
|
|
15
|
-
* });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function updateJsonFileSync(filepath: string, update: (o: Record<string, unknown>) => Record<string, unknown>, defaultJson?: string): void;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateJsonFileSync = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const getJsonIndentation_1 = require("./getJsonIndentation");
|
|
7
|
-
const writeJsonFileSync_1 = require("./writeJsonFileSync");
|
|
8
|
-
/**
|
|
9
|
-
* Updates a JSON file synchronously based on a provided update function.
|
|
10
|
-
* The update function takes the current JSON object as a parameter and should return the updated JSON object.
|
|
11
|
-
* If the update function returns a falsy value, the JSON file will not be written to.
|
|
12
|
-
* The indentation of the original JSON file is preserved.
|
|
13
|
-
*
|
|
14
|
-
* @param filepath - The path to the JSON file to update.
|
|
15
|
-
* @param update - The function to update the JSON object. Takes the current JSON object as a parameter and should return the updated JSON object.
|
|
16
|
-
* @throws If the file cannot be read or written to.
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* updateJsonFileSync('./package.json', (json) => {
|
|
20
|
-
* json.version = '1.0.1';
|
|
21
|
-
* return json;
|
|
22
|
-
* });
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
function updateJsonFileSync(filepath, update, defaultJson) {
|
|
26
|
-
let json;
|
|
27
|
-
try {
|
|
28
|
-
json = fs_1.default.readFileSync(filepath, 'utf8');
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (!defaultJson)
|
|
32
|
-
throw error;
|
|
33
|
-
json = defaultJson;
|
|
34
|
-
}
|
|
35
|
-
const result = update(JSON.parse(json));
|
|
36
|
-
if (!result)
|
|
37
|
-
return;
|
|
38
|
-
const indents = (0, getJsonIndentation_1.getJsonIndentation)(json);
|
|
39
|
-
(0, writeJsonFileSync_1.writeJsonFileSync)(filepath, result, !!indents, indents);
|
|
40
|
-
}
|
|
41
|
-
exports.updateJsonFileSync = updateJsonFileSync;
|
|
42
|
-
//# sourceMappingURL=updateJsonFileSync.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"updateJsonFileSync.js","sourceRoot":"","sources":["../../../../../packages/fs/src/lib/updateJsonFileSync.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AACnB,6DAAyD;AACzD,2DAAuD;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,kBAAkB,CAChC,QAAgB,EAChB,MAA+D,EAC/D,WAAoB;IAEpB,IAAI,IAAY,CAAA;IAChB,IAAI;QACF,IAAI,GAAG,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;KACzC;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,WAAW;YAAE,MAAM,KAAK,CAAA;QAC7B,IAAI,GAAG,WAAW,CAAA;KACnB;IACD,MAAM,MAAM,GAA4B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IAChE,IAAI,CAAC,MAAM;QAAE,OAAM;IACnB,MAAM,OAAO,GAAG,IAAA,uCAAkB,EAAC,IAAI,CAAC,CAAA;IACxC,IAAA,qCAAiB,EAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzD,CAAC;AAhBD,gDAgBC"}
|