@stryke/fs 0.33.32 → 0.33.33
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/CHANGELOG.md +6 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/buffer.cjs +60 -1
- package/dist/buffer.mjs +56 -1
- package/dist/buffer.mjs.map +1 -1
- package/dist/chmod-x.cjs +93 -1
- package/dist/chmod-x.d.cts.map +1 -1
- package/dist/chmod-x.mjs +87 -1
- package/dist/chmod-x.mjs.map +1 -1
- package/dist/command-exists.cjs +102 -1
- package/dist/command-exists.mjs +100 -1
- package/dist/command-exists.mjs.map +1 -1
- package/dist/compress.cjs +29 -1
- package/dist/compress.mjs +28 -1
- package/dist/compress.mjs.map +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/convert/src/array-buffer-to-string.cjs +19 -1
- package/dist/convert/src/array-buffer-to-string.mjs +18 -1
- package/dist/convert/src/array-buffer-to-string.mjs.map +1 -1
- package/dist/convert/src/to-array.cjs +15 -1
- package/dist/convert/src/to-array.mjs +14 -1
- package/dist/convert/src/to-array.mjs.map +1 -1
- package/dist/convert/src/uint8-array-to-string.cjs +15 -1
- package/dist/convert/src/uint8-array-to-string.mjs +15 -1
- package/dist/convert/src/uint8-array-to-string.mjs.map +1 -1
- package/dist/copy-file.cjs +87 -1
- package/dist/copy-file.mjs +83 -1
- package/dist/copy-file.mjs.map +1 -1
- package/dist/exists.cjs +27 -1
- package/dist/exists.mjs +25 -1
- package/dist/exists.mjs.map +1 -1
- package/dist/get-parent-path.cjs +35 -1
- package/dist/get-parent-path.mjs +34 -1
- package/dist/get-parent-path.mjs.map +1 -1
- package/dist/get-workspace-root.cjs +158 -1
- package/dist/get-workspace-root.mjs +150 -1
- package/dist/get-workspace-root.mjs.map +1 -1
- package/dist/helpers/src/get-unique.cjs +14 -1
- package/dist/helpers/src/get-unique.mjs +13 -1
- package/dist/helpers/src/get-unique.mjs.map +1 -1
- package/dist/helpers.cjs +83 -1
- package/dist/helpers.mjs +77 -1
- package/dist/helpers.mjs.map +1 -1
- package/dist/index.cjs +122 -1
- package/dist/index.mjs +25 -1
- package/dist/install.cjs +35 -1
- package/dist/install.mjs +33 -1
- package/dist/install.mjs.map +1 -1
- package/dist/is-file.cjs +51 -1
- package/dist/is-file.mjs +47 -1
- package/dist/is-file.mjs.map +1 -1
- package/dist/json/src/storm-json.cjs +117 -1
- package/dist/json/src/storm-json.mjs +115 -1
- package/dist/json/src/storm-json.mjs.map +1 -1
- package/dist/json/src/utils/code-frames.cjs +77 -3
- package/dist/json/src/utils/code-frames.mjs +76 -3
- package/dist/json/src/utils/code-frames.mjs.map +1 -1
- package/dist/json/src/utils/parse-error.cjs +34 -1
- package/dist/json/src/utils/parse-error.mjs +33 -1
- package/dist/json/src/utils/parse-error.mjs.map +1 -1
- package/dist/json/src/utils/parse.cjs +45 -1
- package/dist/json/src/utils/parse.mjs +45 -1
- package/dist/json/src/utils/parse.mjs.map +1 -1
- package/dist/json/src/utils/stringify.cjs +67 -1
- package/dist/json/src/utils/stringify.mjs +67 -1
- package/dist/json/src/utils/stringify.mjs.map +1 -1
- package/dist/json/src/utils/strip-comments.cjs +86 -4
- package/dist/json/src/utils/strip-comments.mjs +86 -4
- package/dist/json/src/utils/strip-comments.mjs.map +1 -1
- package/dist/json.cjs +74 -1
- package/dist/json.mjs +71 -1
- package/dist/json.mjs.map +1 -1
- package/dist/list-files.cjs +86 -1
- package/dist/list-files.mjs +79 -1
- package/dist/list-files.mjs.map +1 -1
- package/dist/package-fns.cjs +148 -1
- package/dist/package-fns.mjs +141 -1
- package/dist/package-fns.mjs.map +1 -1
- package/dist/path/src/append.cjs +57 -1
- package/dist/path/src/append.mjs +56 -1
- package/dist/path/src/append.mjs.map +1 -1
- package/dist/path/src/correct-path.cjs +138 -1
- package/dist/path/src/correct-path.mjs +134 -1
- package/dist/path/src/correct-path.mjs.map +1 -1
- package/dist/path/src/cwd.cjs +17 -1
- package/dist/path/src/cwd.mjs +16 -1
- package/dist/path/src/cwd.mjs.map +1 -1
- package/dist/path/src/file-path-fns.cjs +169 -1
- package/dist/path/src/file-path-fns.mjs +164 -1
- package/dist/path/src/file-path-fns.mjs.map +1 -1
- package/dist/path/src/is-parent-path.cjs +32 -1
- package/dist/path/src/is-parent-path.mjs +32 -1
- package/dist/path/src/is-parent-path.mjs.map +1 -1
- package/dist/path/src/is-root-dir.cjs +14 -1
- package/dist/path/src/is-root-dir.mjs +13 -1
- package/dist/path/src/is-root-dir.mjs.map +1 -1
- package/dist/path/src/is-type.cjs +68 -1
- package/dist/path/src/is-type.mjs +66 -1
- package/dist/path/src/is-type.mjs.map +1 -1
- package/dist/path/src/join-paths.cjs +106 -1
- package/dist/path/src/join-paths.mjs +106 -1
- package/dist/path/src/join-paths.mjs.map +1 -1
- package/dist/path/src/regex.cjs +18 -1
- package/dist/path/src/regex.mjs +11 -1
- package/dist/path/src/regex.mjs.map +1 -1
- package/dist/path/src/replace.cjs +24 -1
- package/dist/path/src/replace.mjs +24 -1
- package/dist/path/src/replace.mjs.map +1 -1
- package/dist/path/src/resolve-parent-path.cjs +18 -1
- package/dist/path/src/resolve-parent-path.mjs +18 -1
- package/dist/path/src/resolve-parent-path.mjs.map +1 -1
- package/dist/path/src/slash.cjs +15 -1
- package/dist/path/src/slash.mjs +14 -1
- package/dist/path/src/slash.mjs.map +1 -1
- package/dist/read-file.cjs +47 -1
- package/dist/read-file.mjs +43 -1
- package/dist/read-file.mjs.map +1 -1
- package/dist/registry.cjs +142 -1
- package/dist/registry.mjs +137 -1
- package/dist/registry.mjs.map +1 -1
- package/dist/remove-file.cjs +27 -1
- package/dist/remove-file.mjs +25 -1
- package/dist/remove-file.mjs.map +1 -1
- package/dist/resolve.cjs +228 -3
- package/dist/resolve.mjs +217 -3
- package/dist/resolve.mjs.map +1 -1
- package/dist/semver-fns.cjs +129 -1
- package/dist/semver-fns.mjs +119 -1
- package/dist/semver-fns.mjs.map +1 -1
- package/dist/string-format/src/package.cjs +92 -1
- package/dist/string-format/src/package.mjs +91 -1
- package/dist/string-format/src/package.mjs.map +1 -1
- package/dist/toml.cjs +66 -3
- package/dist/toml.mjs +61 -3
- package/dist/toml.mjs.map +1 -1
- package/dist/tsconfig.cjs +37 -1
- package/dist/tsconfig.mjs +35 -1
- package/dist/tsconfig.mjs.map +1 -1
- package/dist/type-checks/src/get-object-tag.cjs +15 -1
- package/dist/type-checks/src/get-object-tag.mjs +14 -1
- package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
- package/dist/type-checks/src/index.cjs +14 -1
- package/dist/type-checks/src/index.mjs +16 -1
- package/dist/type-checks/src/is-buffer.cjs +12 -1
- package/dist/type-checks/src/is-buffer.mjs +11 -1
- package/dist/type-checks/src/is-buffer.mjs.map +1 -1
- package/dist/type-checks/src/is-collection.cjs +1 -1
- package/dist/type-checks/src/is-collection.mjs +3 -1
- package/dist/type-checks/src/is-empty.cjs +20 -1
- package/dist/type-checks/src/is-empty.mjs +20 -1
- package/dist/type-checks/src/is-empty.mjs.map +1 -1
- package/dist/type-checks/src/is-error.cjs +29 -1
- package/dist/type-checks/src/is-error.mjs +29 -1
- package/dist/type-checks/src/is-error.mjs.map +1 -1
- package/dist/type-checks/src/is-null.cjs +12 -1
- package/dist/type-checks/src/is-null.mjs +11 -1
- package/dist/type-checks/src/is-null.mjs.map +1 -1
- package/dist/type-checks/src/is-number.cjs +18 -1
- package/dist/type-checks/src/is-number.mjs +17 -1
- package/dist/type-checks/src/is-number.mjs.map +1 -1
- package/dist/type-checks/src/is-object.cjs +19 -1
- package/dist/type-checks/src/is-object.mjs +19 -1
- package/dist/type-checks/src/is-object.mjs.map +1 -1
- package/dist/type-checks/src/is-plain-object.cjs +64 -1
- package/dist/type-checks/src/is-plain-object.mjs +63 -1
- package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
- package/dist/type-checks/src/is-set-string.cjs +20 -1
- package/dist/type-checks/src/is-set-string.mjs +20 -1
- package/dist/type-checks/src/is-set-string.mjs.map +1 -1
- package/dist/type-checks/src/is-set.cjs +19 -1
- package/dist/type-checks/src/is-set.mjs +19 -1
- package/dist/type-checks/src/is-set.mjs.map +1 -1
- package/dist/type-checks/src/is-string.cjs +12 -1
- package/dist/type-checks/src/is-string.mjs +11 -1
- package/dist/type-checks/src/is-string.mjs.map +1 -1
- package/dist/type-checks/src/is-undefined.cjs +8 -1
- package/dist/type-checks/src/is-undefined.mjs +7 -1
- package/dist/type-checks/src/is-undefined.mjs.map +1 -1
- package/dist/type-checks/src/type-detect.cjs +15 -1
- package/dist/type-checks/src/type-detect.mjs +16 -1
- package/dist/type-checks/src/type-detect.mjs.map +1 -1
- package/dist/types/src/base.cjs +6 -1
- package/dist/types/src/base.mjs +5 -1
- package/dist/types/src/base.mjs.map +1 -1
- package/dist/write-file.cjs +40 -1
- package/dist/write-file.mjs +38 -1
- package/dist/write-file.mjs.map +1 -1
- package/dist/yaml.cjs +29 -1
- package/dist/yaml.mjs +27 -1
- package/dist/yaml.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-exists.mjs","names":["constants"],"sources":["../src/command-exists.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { exec, execSync } from \"node:child_process\";\nimport { accessSync } from \"node:fs\";\nimport { access, constants } from \"node:fs/promises\";\nimport { basename, dirname } from \"node:path\";\n\nconst isUsingWindows = process.platform == \"win32\";\n\nasync function fileNotExists(commandName: string) {\n try {\n await access(commandName, constants.F_OK);\n return false;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return true;\n }\n}\n\nfunction fileNotExistsSync(commandName: string) {\n try {\n accessSync(commandName, constants.F_OK);\n return false;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return true;\n }\n}\n\nasync function localExecutable(commandName: string) {\n return access(commandName, constants.F_OK | constants.X_OK);\n}\n\nfunction localExecutableSync(commandName: string) {\n try {\n accessSync(commandName, constants.F_OK | constants.X_OK);\n return true;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return false;\n }\n}\n\nasync function commandExistsUnix(\n commandName: string,\n cleanedCommandName: string\n) {\n const isFile = await fileNotExists(commandName);\n\n if (!isFile) {\n exec(\n `command -v ${cleanedCommandName} 2>/dev/null` +\n ` && { echo >&1 ${cleanedCommandName}; exit 0; }`\n );\n\n await localExecutable(commandName);\n }\n}\n\nasync function commandExistsWindows(\n commandName: string,\n cleanedCommandName: string\n) {\n // Regex from Julio from: https://stackoverflow.com/questions/51494579/regex-windows-path-validator\n if (!/^(?!(?:.*\\s|.*\\.|\\W+)$)(?:[a-z]:)?[^<>:\"|?*\\n]+$/im.test(commandName)) {\n return;\n }\n\n exec(`where ${cleanedCommandName}`);\n}\n\nfunction commandExistsUnixSync(\n commandName: string,\n cleanedCommandName: string\n): boolean {\n if (fileNotExistsSync(commandName)) {\n try {\n const stdout = execSync(\n `command -v ${cleanedCommandName} 2>/dev/null` +\n ` && { echo >&1 ${cleanedCommandName}; exit 0; }`\n );\n\n return !!stdout;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return false;\n }\n }\n return localExecutableSync(commandName);\n}\n\nfunction commandExistsWindowsSync(\n commandName: string,\n cleanedCommandName: string\n) {\n // Regex from Julio from: https://stackoverflow.com/questions/51494579/regex-windows-path-validator\n if (!/^(?!(?:.*\\s|.*\\.|\\W+)$)(?:[a-z]:)?[^<>:\"|?*\\n]+$/im.test(commandName)) {\n return false;\n }\n try {\n const stdout = execSync(`where ${cleanedCommandName}`, { stdio: [] });\n\n return !!stdout;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return false;\n }\n}\n\nfunction cleanInput(s: string) {\n if (/[^\\w/:=-]/.test(s)) {\n s = `'${s.replace(/'/g, \"'\\\\''\")}'`;\n s = s\n .replace(/^(?:'')+/g, \"\") // un-duplicate single-quote at the beginning\n .replace(/\\\\'''/g, \"\\\\'\"); // remove non-escaped single-quote if there are enclosed between 2 escaped\n }\n return s;\n}\n\nconst cleanWindowsInput = (s: string) => {\n const isPathName = /\\\\/.test(s);\n if (isPathName) {\n return `\"${dirname(s)}:${basename(s)}\"`;\n }\n return `\"${s}\"`;\n};\n\n/**\n * Asynchronously checks if a command exists in the system.\n *\n * @remarks\n * This function will check if the command is available in the system's PATH and if it is executable.\n * @param commandName - The name of the command to check for existence\n * @returns A promise that resolves to `true` if the command exists and is executable, `false` otherwise\n */\nexport async function commandExists(commandName: string) {\n const cleanedCommandName = cleanInput(commandName);\n\n if (typeof Promise !== \"undefined\") {\n return commandExists(commandName);\n }\n if (isUsingWindows) {\n return commandExistsWindows(commandName, cleanedCommandName);\n } else {\n return commandExistsUnix(commandName, cleanedCommandName);\n }\n}\n\n/**\n * Synchronously checks if a command exists in the system.\n *\n * @remarks\n * This function will check if the command is available in the system's PATH and if it is executable.\n * @param commandName - The name of the command to check for existence\n * @returns `true` if the command exists and is executable, `false` otherwise\n */\nexport function commandExistsSync(commandName: string): boolean {\n if (isUsingWindows) {\n return commandExistsWindowsSync(\n commandName,\n cleanWindowsInput(commandName)\n );\n } else {\n return commandExistsUnixSync(commandName, cleanInput(commandName));\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-exists.mjs","names":["constants"],"sources":["../src/command-exists.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { exec, execSync } from \"node:child_process\";\nimport { accessSync } from \"node:fs\";\nimport { access, constants } from \"node:fs/promises\";\nimport { basename, dirname } from \"node:path\";\n\nconst isUsingWindows = process.platform == \"win32\";\n\nasync function fileNotExists(commandName: string) {\n try {\n await access(commandName, constants.F_OK);\n return false;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return true;\n }\n}\n\nfunction fileNotExistsSync(commandName: string) {\n try {\n accessSync(commandName, constants.F_OK);\n return false;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return true;\n }\n}\n\nasync function localExecutable(commandName: string) {\n return access(commandName, constants.F_OK | constants.X_OK);\n}\n\nfunction localExecutableSync(commandName: string) {\n try {\n accessSync(commandName, constants.F_OK | constants.X_OK);\n return true;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return false;\n }\n}\n\nasync function commandExistsUnix(\n commandName: string,\n cleanedCommandName: string\n) {\n const isFile = await fileNotExists(commandName);\n\n if (!isFile) {\n exec(\n `command -v ${cleanedCommandName} 2>/dev/null` +\n ` && { echo >&1 ${cleanedCommandName}; exit 0; }`\n );\n\n await localExecutable(commandName);\n }\n}\n\nasync function commandExistsWindows(\n commandName: string,\n cleanedCommandName: string\n) {\n // Regex from Julio from: https://stackoverflow.com/questions/51494579/regex-windows-path-validator\n if (!/^(?!(?:.*\\s|.*\\.|\\W+)$)(?:[a-z]:)?[^<>:\"|?*\\n]+$/im.test(commandName)) {\n return;\n }\n\n exec(`where ${cleanedCommandName}`);\n}\n\nfunction commandExistsUnixSync(\n commandName: string,\n cleanedCommandName: string\n): boolean {\n if (fileNotExistsSync(commandName)) {\n try {\n const stdout = execSync(\n `command -v ${cleanedCommandName} 2>/dev/null` +\n ` && { echo >&1 ${cleanedCommandName}; exit 0; }`\n );\n\n return !!stdout;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return false;\n }\n }\n return localExecutableSync(commandName);\n}\n\nfunction commandExistsWindowsSync(\n commandName: string,\n cleanedCommandName: string\n) {\n // Regex from Julio from: https://stackoverflow.com/questions/51494579/regex-windows-path-validator\n if (!/^(?!(?:.*\\s|.*\\.|\\W+)$)(?:[a-z]:)?[^<>:\"|?*\\n]+$/im.test(commandName)) {\n return false;\n }\n try {\n const stdout = execSync(`where ${cleanedCommandName}`, { stdio: [] });\n\n return !!stdout;\n // eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars\n } catch (_) {\n return false;\n }\n}\n\nfunction cleanInput(s: string) {\n if (/[^\\w/:=-]/.test(s)) {\n s = `'${s.replace(/'/g, \"'\\\\''\")}'`;\n s = s\n .replace(/^(?:'')+/g, \"\") // un-duplicate single-quote at the beginning\n .replace(/\\\\'''/g, \"\\\\'\"); // remove non-escaped single-quote if there are enclosed between 2 escaped\n }\n return s;\n}\n\nconst cleanWindowsInput = (s: string) => {\n const isPathName = /\\\\/.test(s);\n if (isPathName) {\n return `\"${dirname(s)}:${basename(s)}\"`;\n }\n return `\"${s}\"`;\n};\n\n/**\n * Asynchronously checks if a command exists in the system.\n *\n * @remarks\n * This function will check if the command is available in the system's PATH and if it is executable.\n * @param commandName - The name of the command to check for existence\n * @returns A promise that resolves to `true` if the command exists and is executable, `false` otherwise\n */\nexport async function commandExists(commandName: string) {\n const cleanedCommandName = cleanInput(commandName);\n\n if (typeof Promise !== \"undefined\") {\n return commandExists(commandName);\n }\n if (isUsingWindows) {\n return commandExistsWindows(commandName, cleanedCommandName);\n } else {\n return commandExistsUnix(commandName, cleanedCommandName);\n }\n}\n\n/**\n * Synchronously checks if a command exists in the system.\n *\n * @remarks\n * This function will check if the command is available in the system's PATH and if it is executable.\n * @param commandName - The name of the command to check for existence\n * @returns `true` if the command exists and is executable, `false` otherwise\n */\nexport function commandExistsSync(commandName: string): boolean {\n if (isUsingWindows) {\n return commandExistsWindowsSync(\n commandName,\n cleanWindowsInput(commandName)\n );\n } else {\n return commandExistsUnixSync(commandName, cleanInput(commandName));\n }\n}\n"],"mappings":";;;;;;AAuBA,MAAM,iBAAiB,QAAQ,YAAY;AAE3C,eAAe,cAAc,aAAqB;AAChD,KAAI;AACF,QAAM,OAAO,aAAaA,YAAU,KAAK;AACzC,SAAO;UAEA,GAAG;AACV,SAAO;;;AAIX,SAAS,kBAAkB,aAAqB;AAC9C,KAAI;AACF,aAAW,aAAaA,YAAU,KAAK;AACvC,SAAO;UAEA,GAAG;AACV,SAAO;;;AAIX,eAAe,gBAAgB,aAAqB;AAClD,QAAO,OAAO,aAAaA,YAAU,OAAOA,YAAU,KAAK;;AAG7D,SAAS,oBAAoB,aAAqB;AAChD,KAAI;AACF,aAAW,aAAaA,YAAU,OAAOA,YAAU,KAAK;AACxD,SAAO;UAEA,GAAG;AACV,SAAO;;;AAIX,eAAe,kBACb,aACA,oBACA;AAGA,KAAI,CAFW,MAAM,cAAc,YAAY,EAElC;AACX,OACE,cAAc,mBAAmB,6BACb,mBAAmB,aACxC;AAED,QAAM,gBAAgB,YAAY;;;AAItC,eAAe,qBACb,aACA,oBACA;AAEA,KAAI,CAAC,qDAAqD,KAAK,YAAY,CACzE;AAGF,MAAK,SAAS,qBAAqB;;AAGrC,SAAS,sBACP,aACA,oBACS;AACT,KAAI,kBAAkB,YAAY,CAChC,KAAI;AAMF,SAAO,CAAC,CALO,SACb,cAAc,mBAAmB,6BACb,mBAAmB,aACxC;UAIM,GAAG;AACV,SAAO;;AAGX,QAAO,oBAAoB,YAAY;;AAGzC,SAAS,yBACP,aACA,oBACA;AAEA,KAAI,CAAC,qDAAqD,KAAK,YAAY,CACzE,QAAO;AAET,KAAI;AAGF,SAAO,CAAC,CAFO,SAAS,SAAS,sBAAsB,EAAE,OAAO,EAAE,EAAE,CAAC;UAI9D,GAAG;AACV,SAAO;;;AAIX,SAAS,WAAW,GAAW;AAC7B,KAAI,YAAY,KAAK,EAAE,EAAE;AACvB,MAAI,IAAI,EAAE,QAAQ,MAAM,QAAQ,CAAC;AACjC,MAAI,EACD,QAAQ,aAAa,GAAG,CACxB,QAAQ,UAAU,MAAM;;AAE7B,QAAO;;AAGT,MAAM,qBAAqB,MAAc;AAEvC,KADmB,KAAK,KAAK,EAAE,CAE7B,QAAO,IAAI,QAAQ,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC;AAEvC,QAAO,IAAI,EAAE;;;;;;;;;;AAWf,eAAsB,cAAc,aAAqB;CACvD,MAAM,qBAAqB,WAAW,YAAY;AAElD,KAAI,OAAO,YAAY,YACrB,QAAO,cAAc,YAAY;AAEnC,KAAI,eACF,QAAO,qBAAqB,aAAa,mBAAmB;KAE5D,QAAO,kBAAkB,aAAa,mBAAmB;;;;;;;;;;AAY7D,SAAgB,kBAAkB,aAA8B;AAC9D,KAAI,eACF,QAAO,yBACL,aACA,kBAAkB,YAAY,CAC/B;KAED,QAAO,sBAAsB,aAAa,WAAW,YAAY,CAAC"}
|
package/dist/compress.cjs
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_join_paths = require('./path/src/join-paths.cjs');
|
|
3
|
+
const require_file_path_fns = require('./path/src/file-path-fns.cjs');
|
|
4
|
+
const require_resolve_parent_path = require('./path/src/resolve-parent-path.cjs');
|
|
5
|
+
const require_uint8_array_to_string = require('./convert/src/uint8-array-to-string.cjs');
|
|
6
|
+
const require_is_file = require('./is-file.cjs');
|
|
7
|
+
const require_list_files = require('./list-files.cjs');
|
|
8
|
+
const require_read_file = require('./read-file.cjs');
|
|
9
|
+
const require_write_file = require('./write-file.cjs');
|
|
10
|
+
let nanotar = require("nanotar");
|
|
11
|
+
|
|
12
|
+
//#region src/compress.ts
|
|
13
|
+
/**
|
|
14
|
+
* Compress a directory or file into a tar.gz archive.
|
|
15
|
+
*
|
|
16
|
+
* @param directory - The source directory or file/glob to compress.
|
|
17
|
+
* @param options - Options for the compression.
|
|
18
|
+
*/
|
|
19
|
+
async function compressDirectory(directory, options) {
|
|
20
|
+
const files = await require_list_files.listFiles(require_is_file.isDirectory(directory) ? require_join_paths.joinPaths(directory, "**/*") : directory, options);
|
|
21
|
+
const data = await (0, nanotar.createTarGzip)(await Promise.all(files.map(async (file) => ({
|
|
22
|
+
name: file,
|
|
23
|
+
data: await require_read_file.readFileIfExisting(file)
|
|
24
|
+
}))), { attrs: { group: "storm-software" } });
|
|
25
|
+
return require_write_file.writeFile(options?.destination ? require_is_file.isDirectory(options.destination) ? require_join_paths.joinPaths(options.destination, `${(/* @__PURE__ */ new Date()).getTime()}.tar.gz`) : options.destination : require_is_file.isDirectory(directory) ? `${require_join_paths.joinPaths(require_resolve_parent_path.resolveParentPath(directory), require_file_path_fns.findFolderName(directory))}.tar.gz` : directory, require_uint8_array_to_string.uint8ArrayToString(data));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.compressDirectory = compressDirectory;
|
package/dist/compress.mjs
CHANGED
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
import{joinPaths
|
|
1
|
+
import { joinPaths } from "./path/src/join-paths.mjs";
|
|
2
|
+
import { findFolderName } from "./path/src/file-path-fns.mjs";
|
|
3
|
+
import { resolveParentPath } from "./path/src/resolve-parent-path.mjs";
|
|
4
|
+
import { uint8ArrayToString } from "./convert/src/uint8-array-to-string.mjs";
|
|
5
|
+
import { isDirectory } from "./is-file.mjs";
|
|
6
|
+
import { listFiles } from "./list-files.mjs";
|
|
7
|
+
import { readFileIfExisting } from "./read-file.mjs";
|
|
8
|
+
import { writeFile } from "./write-file.mjs";
|
|
9
|
+
import { createTarGzip } from "nanotar";
|
|
10
|
+
|
|
11
|
+
//#region src/compress.ts
|
|
12
|
+
/**
|
|
13
|
+
* Compress a directory or file into a tar.gz archive.
|
|
14
|
+
*
|
|
15
|
+
* @param directory - The source directory or file/glob to compress.
|
|
16
|
+
* @param options - Options for the compression.
|
|
17
|
+
*/
|
|
18
|
+
async function compressDirectory(directory, options) {
|
|
19
|
+
const files = await listFiles(isDirectory(directory) ? joinPaths(directory, "**/*") : directory, options);
|
|
20
|
+
const data = await createTarGzip(await Promise.all(files.map(async (file) => ({
|
|
21
|
+
name: file,
|
|
22
|
+
data: await readFileIfExisting(file)
|
|
23
|
+
}))), { attrs: { group: "storm-software" } });
|
|
24
|
+
return writeFile(options?.destination ? isDirectory(options.destination) ? joinPaths(options.destination, `${(/* @__PURE__ */ new Date()).getTime()}.tar.gz`) : options.destination : isDirectory(directory) ? `${joinPaths(resolveParentPath(directory), findFolderName(directory))}.tar.gz` : directory, uint8ArrayToString(data));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { compressDirectory };
|
|
2
29
|
//# sourceMappingURL=compress.mjs.map
|
package/dist/compress.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.mjs","names":[],"sources":["../src/compress.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { uint8ArrayToString } from \"@stryke/convert/uint8-array-to-string\";\nimport { findFolderName, resolveParentPath } from \"@stryke/path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { GlobOptions } from \"glob\";\nimport { createTarGzip } from \"nanotar\";\nimport { isDirectory } from \"./is-file\";\nimport { listFiles } from \"./list-files\";\nimport { readFileIfExisting } from \"./read-file\";\nimport { writeFile } from \"./write-file\";\n\nexport interface CompressDirectoryOptions extends GlobOptions {\n destination?: string;\n}\n\n/**\n * Compress a directory or file into a tar.gz archive.\n *\n * @param directory - The source directory or file/glob to compress.\n * @param options - Options for the compression.\n */\nexport async function compressDirectory(\n directory: string,\n options?: CompressDirectoryOptions\n): Promise<void> {\n const files = await listFiles(\n isDirectory(directory) ? joinPaths(directory, \"**/*\") : directory,\n options\n );\n const data = await createTarGzip(\n await Promise.all(\n files.map(async file => ({\n name: file,\n data: await readFileIfExisting(file)\n }))\n ),\n {\n attrs: { group: \"storm-software\" }\n }\n );\n\n return writeFile(\n options?.destination\n ? isDirectory(options.destination)\n ? joinPaths(options.destination, `${new Date().getTime()}.tar.gz`)\n : options.destination\n : isDirectory(directory)\n ? `${joinPaths(resolveParentPath(directory), findFolderName(directory))}.tar.gz`\n : directory,\n uint8ArrayToString(data)\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"compress.mjs","names":[],"sources":["../src/compress.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { uint8ArrayToString } from \"@stryke/convert/uint8-array-to-string\";\nimport { findFolderName, resolveParentPath } from \"@stryke/path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { GlobOptions } from \"glob\";\nimport { createTarGzip } from \"nanotar\";\nimport { isDirectory } from \"./is-file\";\nimport { listFiles } from \"./list-files\";\nimport { readFileIfExisting } from \"./read-file\";\nimport { writeFile } from \"./write-file\";\n\nexport interface CompressDirectoryOptions extends GlobOptions {\n destination?: string;\n}\n\n/**\n * Compress a directory or file into a tar.gz archive.\n *\n * @param directory - The source directory or file/glob to compress.\n * @param options - Options for the compression.\n */\nexport async function compressDirectory(\n directory: string,\n options?: CompressDirectoryOptions\n): Promise<void> {\n const files = await listFiles(\n isDirectory(directory) ? joinPaths(directory, \"**/*\") : directory,\n options\n );\n const data = await createTarGzip(\n await Promise.all(\n files.map(async file => ({\n name: file,\n data: await readFileIfExisting(file)\n }))\n ),\n {\n attrs: { group: \"storm-software\" }\n }\n );\n\n return writeFile(\n options?.destination\n ? isDirectory(options.destination)\n ? joinPaths(options.destination, `${new Date().getTime()}.tar.gz`)\n : options.destination\n : isDirectory(directory)\n ? `${joinPaths(resolveParentPath(directory), findFolderName(directory))}.tar.gz`\n : directory,\n uint8ArrayToString(data)\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsCA,eAAsB,kBACpB,WACA,SACe;CACf,MAAM,QAAQ,MAAM,UAClB,YAAY,UAAU,GAAG,UAAU,WAAW,OAAO,GAAG,WACxD,QACD;CACD,MAAM,OAAO,MAAM,cACjB,MAAM,QAAQ,IACZ,MAAM,IAAI,OAAM,UAAS;EACvB,MAAM;EACN,MAAM,MAAM,mBAAmB,KAAK;EACrC,EAAE,CACJ,EACD,EACE,OAAO,EAAE,OAAO,kBAAkB,EACnC,CACF;AAED,QAAO,UACL,SAAS,cACL,YAAY,QAAQ,YAAY,GAC9B,UAAU,QAAQ,aAAa,oBAAG,IAAI,MAAM,EAAC,SAAS,CAAC,SAAS,GAChE,QAAQ,cACV,YAAY,UAAU,GACpB,GAAG,UAAU,kBAAkB,UAAU,EAAE,eAAe,UAAU,CAAC,CAAC,WACtE,WACN,mBAAmB,KAAK,CACzB"}
|
package/dist/constants.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region ../convert/src/array-buffer-to-string.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convert an ArrayBuffer or Uint8Array to a string
|
|
5
|
+
*
|
|
6
|
+
* @param buffer - The ArrayBuffer or Uint8Array to convert
|
|
7
|
+
* @returns The converted string
|
|
8
|
+
*/
|
|
9
|
+
function arrayBufferToString(buffer) {
|
|
10
|
+
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
11
|
+
const len = bytes.byteLength;
|
|
12
|
+
if (len < 65535) return String.fromCharCode.apply(null, bytes);
|
|
13
|
+
let binary = "";
|
|
14
|
+
for (let i = 0; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
15
|
+
return binary;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.arrayBufferToString = arrayBufferToString;
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
//#region ../convert/src/array-buffer-to-string.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert an ArrayBuffer or Uint8Array to a string
|
|
4
|
+
*
|
|
5
|
+
* @param buffer - The ArrayBuffer or Uint8Array to convert
|
|
6
|
+
* @returns The converted string
|
|
7
|
+
*/
|
|
8
|
+
function arrayBufferToString(buffer) {
|
|
9
|
+
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
10
|
+
const len = bytes.byteLength;
|
|
11
|
+
if (len < 65535) return String.fromCharCode.apply(null, bytes);
|
|
12
|
+
let binary = "";
|
|
13
|
+
for (let i = 0; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
14
|
+
return binary;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { arrayBufferToString };
|
|
2
19
|
//# sourceMappingURL=array-buffer-to-string.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-buffer-to-string.mjs","names":[],"sources":["../../../../convert/src/array-buffer-to-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert an ArrayBuffer or Uint8Array to a string\n *\n * @param buffer - The ArrayBuffer or Uint8Array to convert\n * @returns The converted string\n */\nexport function arrayBufferToString(\n buffer: ArrayBuffer | ArrayBufferLike | Uint8Array\n): string {\n const bytes =\n buffer instanceof Uint8Array\n ? buffer\n : new Uint8Array(buffer as ArrayBufferLike);\n const len = bytes.byteLength;\n if (len < 65535) {\n return String.fromCharCode.apply(null, bytes as unknown as number[]);\n }\n let binary = \"\";\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]!);\n }\n return binary;\n}\n"],"mappings":"AAwBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"array-buffer-to-string.mjs","names":[],"sources":["../../../../convert/src/array-buffer-to-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert an ArrayBuffer or Uint8Array to a string\n *\n * @param buffer - The ArrayBuffer or Uint8Array to convert\n * @returns The converted string\n */\nexport function arrayBufferToString(\n buffer: ArrayBuffer | ArrayBufferLike | Uint8Array\n): string {\n const bytes =\n buffer instanceof Uint8Array\n ? buffer\n : new Uint8Array(buffer as ArrayBufferLike);\n const len = bytes.byteLength;\n if (len < 65535) {\n return String.fromCharCode.apply(null, bytes as unknown as number[]);\n }\n let binary = \"\";\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]!);\n }\n return binary;\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,oBACd,QACQ;CACR,MAAM,QACJ,kBAAkB,aACd,SACA,IAAI,WAAW,OAA0B;CAC/C,MAAM,MAAM,MAAM;AAClB,KAAI,MAAM,MACR,QAAO,OAAO,aAAa,MAAM,MAAM,MAA6B;CAEtE,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IACvB,WAAU,OAAO,aAAa,MAAM,GAAI;AAE1C,QAAO"}
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region ../convert/src/to-array.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convert `Arrayable<T>` to `Array<T>`
|
|
5
|
+
*
|
|
6
|
+
* @param array - The `Arrayable<T>` to convert
|
|
7
|
+
* @returns An `Array<T>` containing the elements of the input
|
|
8
|
+
*/
|
|
9
|
+
function toArray(array) {
|
|
10
|
+
array = array ?? [];
|
|
11
|
+
return Array.isArray(array) ? array : [array];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.toArray = toArray;
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
//#region ../convert/src/to-array.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert `Arrayable<T>` to `Array<T>`
|
|
4
|
+
*
|
|
5
|
+
* @param array - The `Arrayable<T>` to convert
|
|
6
|
+
* @returns An `Array<T>` containing the elements of the input
|
|
7
|
+
*/
|
|
8
|
+
function toArray(array) {
|
|
9
|
+
array = array ?? [];
|
|
10
|
+
return Array.isArray(array) ? array : [array];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { toArray };
|
|
2
15
|
//# sourceMappingURL=to-array.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-array.mjs","names":[],"sources":["../../../../convert/src/to-array.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Arrayable } from \"@stryke/types/array\";\nimport type { Nullable } from \"@stryke/types/utilities\";\n\n/**\n * Convert `Arrayable<T>` to `Array<T>`\n *\n * @param array - The `Arrayable<T>` to convert\n * @returns An `Array<T>` containing the elements of the input\n */\nexport function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T> {\n array = array ?? [];\n return Array.isArray(array) ? array : [array];\n}\n"],"mappings":"AA2BA,SAAgB,
|
|
1
|
+
{"version":3,"file":"to-array.mjs","names":[],"sources":["../../../../convert/src/to-array.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Arrayable } from \"@stryke/types/array\";\nimport type { Nullable } from \"@stryke/types/utilities\";\n\n/**\n * Convert `Arrayable<T>` to `Array<T>`\n *\n * @param array - The `Arrayable<T>` to convert\n * @returns An `Array<T>` containing the elements of the input\n */\nexport function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T> {\n array = array ?? [];\n return Array.isArray(array) ? array : [array];\n}\n"],"mappings":";;;;;;;AA2BA,SAAgB,QAAW,OAA0C;AACnE,SAAQ,SAAS,EAAE;AACnB,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM"}
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_array_buffer_to_string = require('./array-buffer-to-string.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../convert/src/uint8-array-to-string.ts
|
|
4
|
+
/**
|
|
5
|
+
* Convert a Uint8Array to a base64 string
|
|
6
|
+
*
|
|
7
|
+
* @param buffer - The Uint8Array to convert
|
|
8
|
+
* @returns The converted base64 string
|
|
9
|
+
*/
|
|
10
|
+
function uint8ArrayToString(buffer) {
|
|
11
|
+
return btoa(require_array_buffer_to_string.arrayBufferToString(buffer));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.uint8ArrayToString = uint8ArrayToString;
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
import{arrayBufferToString
|
|
1
|
+
import { arrayBufferToString } from "./array-buffer-to-string.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../convert/src/uint8-array-to-string.ts
|
|
4
|
+
/**
|
|
5
|
+
* Convert a Uint8Array to a base64 string
|
|
6
|
+
*
|
|
7
|
+
* @param buffer - The Uint8Array to convert
|
|
8
|
+
* @returns The converted base64 string
|
|
9
|
+
*/
|
|
10
|
+
function uint8ArrayToString(buffer) {
|
|
11
|
+
return btoa(arrayBufferToString(buffer));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { uint8ArrayToString };
|
|
2
16
|
//# sourceMappingURL=uint8-array-to-string.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint8-array-to-string.mjs","names":[],"sources":["../../../../convert/src/uint8-array-to-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { arrayBufferToString } from \"./array-buffer-to-string\";\n\n/**\n * Convert a Uint8Array to a base64 string\n *\n * @param buffer - The Uint8Array to convert\n * @returns The converted base64 string\n */\nexport function uint8ArrayToString(buffer: Uint8Array): string {\n return btoa(arrayBufferToString(buffer));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"uint8-array-to-string.mjs","names":[],"sources":["../../../../convert/src/uint8-array-to-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { arrayBufferToString } from \"./array-buffer-to-string\";\n\n/**\n * Convert a Uint8Array to a base64 string\n *\n * @param buffer - The Uint8Array to convert\n * @returns The converted base64 string\n */\nexport function uint8ArrayToString(buffer: Uint8Array): string {\n return btoa(arrayBufferToString(buffer));\n}\n"],"mappings":";;;;;;;;;AA0BA,SAAgB,mBAAmB,QAA4B;AAC7D,QAAO,KAAK,oBAAoB,OAAO,CAAC"}
|
package/dist/copy-file.cjs
CHANGED
|
@@ -1 +1,87 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_join_paths = require('./path/src/join-paths.cjs');
|
|
3
|
+
const require_correct_path = require('./path/src/correct-path.cjs');
|
|
4
|
+
const require_is_string = require('./type-checks/src/is-string.cjs');
|
|
5
|
+
const require_file_path_fns = require('./path/src/file-path-fns.cjs');
|
|
6
|
+
const require_replace = require('./path/src/replace.cjs');
|
|
7
|
+
const require_resolve_parent_path = require('./path/src/resolve-parent-path.cjs');
|
|
8
|
+
const require_exists = require('./exists.cjs');
|
|
9
|
+
const require_helpers = require('./helpers.cjs');
|
|
10
|
+
const require_is_file = require('./is-file.cjs');
|
|
11
|
+
require('./type-checks/src/index.cjs');
|
|
12
|
+
const require_list_files = require('./list-files.cjs');
|
|
13
|
+
let node_fs = require("node:fs");
|
|
14
|
+
let node_fs_promises = require("node:fs/promises");
|
|
15
|
+
let mlly = require("mlly");
|
|
16
|
+
|
|
17
|
+
//#region src/copy-file.ts
|
|
18
|
+
/**
|
|
19
|
+
* Copy a file from one location to another
|
|
20
|
+
*
|
|
21
|
+
* @param source - The file to copy, this can be a file, directory, URL, or glob pattern
|
|
22
|
+
* @param destination - The destination location
|
|
23
|
+
* @returns An indicator specifying if the copy was successful
|
|
24
|
+
*/
|
|
25
|
+
async function copyFile(source, destination) {
|
|
26
|
+
const src = source instanceof URL ? (0, mlly.fileURLToPath)(source) : source;
|
|
27
|
+
const dest = destination instanceof URL ? (0, mlly.fileURLToPath)(destination) : destination;
|
|
28
|
+
if (!require_file_path_fns.hasFileExtension(dest)) {
|
|
29
|
+
if (!require_exists.existsSync(require_resolve_parent_path.resolveParentPath(dest))) await require_helpers.createDirectory(require_resolve_parent_path.resolveParentPath(dest));
|
|
30
|
+
} else if (!require_exists.existsSync(require_file_path_fns.findFilePath(dest))) await require_helpers.createDirectory(require_file_path_fns.findFilePath(dest));
|
|
31
|
+
if (require_is_string.isString(src) && require_exists.existsSync(src)) return (0, node_fs_promises.copyFile)(src, dest);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Synchronously copy a file from one location to another
|
|
35
|
+
*
|
|
36
|
+
* @param source - The file to copy, this can be a file, directory, URL, or glob pattern
|
|
37
|
+
* @param destination - The destination location
|
|
38
|
+
* @returns An indicator specifying if the copy was successful
|
|
39
|
+
*/
|
|
40
|
+
function copyFileSync(source, destination) {
|
|
41
|
+
const src = source instanceof URL ? (0, mlly.fileURLToPath)(source) : source;
|
|
42
|
+
const dest = destination instanceof URL ? (0, mlly.fileURLToPath)(destination) : destination;
|
|
43
|
+
if (!require_file_path_fns.hasFileExtension(dest)) {
|
|
44
|
+
if (!require_exists.existsSync(require_resolve_parent_path.resolveParentPath(dest))) require_helpers.createDirectorySync(require_resolve_parent_path.resolveParentPath(dest));
|
|
45
|
+
} else if (!require_exists.existsSync(require_file_path_fns.findFilePath(dest))) require_helpers.createDirectorySync(require_file_path_fns.findFilePath(dest));
|
|
46
|
+
if (require_is_string.isString(src) && require_exists.existsSync(src)) return (0, node_fs.copyFileSync)(src, dest);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Copy files from one location to another
|
|
50
|
+
*
|
|
51
|
+
* @param source - The source location, this can be a file, directory, URL, or glob pattern
|
|
52
|
+
* @param destination - The destination location
|
|
53
|
+
* @returns An indicator specifying if the copy was successful
|
|
54
|
+
*/
|
|
55
|
+
async function copyFiles(source, destination) {
|
|
56
|
+
const src = source instanceof URL ? (0, mlly.fileURLToPath)(source) : source;
|
|
57
|
+
const dest = destination instanceof URL ? (0, mlly.fileURLToPath)(destination) : destination;
|
|
58
|
+
if (require_is_string.isString(src) && require_is_file.isFile(src)) return copyFile(src, dest);
|
|
59
|
+
return Promise.all((await require_list_files.listFiles(src)).map(async (entryPath) => {
|
|
60
|
+
const destFile = require_join_paths.joinPaths(dest, require_replace.replacePath(entryPath, require_is_string.isString(src) ? require_correct_path.stripStars(src) : src.input));
|
|
61
|
+
if (require_is_file.isDirectory(entryPath)) await copyFiles(entryPath, destFile);
|
|
62
|
+
else await copyFile(entryPath, destFile);
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Synchronously copy files from one location to another
|
|
67
|
+
*
|
|
68
|
+
* @param source - The source location, this can be a file, directory, URL, or glob pattern
|
|
69
|
+
* @param destination - The destination location
|
|
70
|
+
* @returns An indicator specifying if the copy was successful
|
|
71
|
+
*/
|
|
72
|
+
function copyFilesSync(source, destination) {
|
|
73
|
+
const src = source instanceof URL ? (0, mlly.fileURLToPath)(source) : source;
|
|
74
|
+
const dest = destination instanceof URL ? (0, mlly.fileURLToPath)(destination) : destination;
|
|
75
|
+
if (require_is_string.isString(src) && require_is_file.isFile(src)) return copyFileSync(src, dest);
|
|
76
|
+
return require_list_files.listFilesSync(src).map((entryPath) => {
|
|
77
|
+
const destFile = require_join_paths.joinPaths(dest, require_replace.replacePath(entryPath, require_is_string.isString(src) ? require_correct_path.stripStars(src) : src.input));
|
|
78
|
+
if (require_is_file.isDirectory(entryPath)) copyFilesSync(entryPath, destFile);
|
|
79
|
+
else copyFileSync(entryPath, destFile);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
exports.copyFile = copyFile;
|
|
85
|
+
exports.copyFileSync = copyFileSync;
|
|
86
|
+
exports.copyFiles = copyFiles;
|
|
87
|
+
exports.copyFilesSync = copyFilesSync;
|
package/dist/copy-file.mjs
CHANGED
|
@@ -1,2 +1,84 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { joinPaths } from "./path/src/join-paths.mjs";
|
|
2
|
+
import { stripStars } from "./path/src/correct-path.mjs";
|
|
3
|
+
import { isString } from "./type-checks/src/is-string.mjs";
|
|
4
|
+
import { findFilePath, hasFileExtension } from "./path/src/file-path-fns.mjs";
|
|
5
|
+
import { replacePath } from "./path/src/replace.mjs";
|
|
6
|
+
import { resolveParentPath } from "./path/src/resolve-parent-path.mjs";
|
|
7
|
+
import { existsSync as existsSync$1 } from "./exists.mjs";
|
|
8
|
+
import { createDirectory, createDirectorySync } from "./helpers.mjs";
|
|
9
|
+
import { isDirectory, isFile } from "./is-file.mjs";
|
|
10
|
+
import "./type-checks/src/index.mjs";
|
|
11
|
+
import { listFiles, listFilesSync } from "./list-files.mjs";
|
|
12
|
+
import { copyFileSync as copyFileSync$1 } from "node:fs";
|
|
13
|
+
import { copyFile as copyFile$1 } from "node:fs/promises";
|
|
14
|
+
import { fileURLToPath } from "mlly";
|
|
15
|
+
|
|
16
|
+
//#region src/copy-file.ts
|
|
17
|
+
/**
|
|
18
|
+
* Copy a file from one location to another
|
|
19
|
+
*
|
|
20
|
+
* @param source - The file to copy, this can be a file, directory, URL, or glob pattern
|
|
21
|
+
* @param destination - The destination location
|
|
22
|
+
* @returns An indicator specifying if the copy was successful
|
|
23
|
+
*/
|
|
24
|
+
async function copyFile(source, destination) {
|
|
25
|
+
const src = source instanceof URL ? fileURLToPath(source) : source;
|
|
26
|
+
const dest = destination instanceof URL ? fileURLToPath(destination) : destination;
|
|
27
|
+
if (!hasFileExtension(dest)) {
|
|
28
|
+
if (!existsSync$1(resolveParentPath(dest))) await createDirectory(resolveParentPath(dest));
|
|
29
|
+
} else if (!existsSync$1(findFilePath(dest))) await createDirectory(findFilePath(dest));
|
|
30
|
+
if (isString(src) && existsSync$1(src)) return copyFile$1(src, dest);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Synchronously copy a file from one location to another
|
|
34
|
+
*
|
|
35
|
+
* @param source - The file to copy, this can be a file, directory, URL, or glob pattern
|
|
36
|
+
* @param destination - The destination location
|
|
37
|
+
* @returns An indicator specifying if the copy was successful
|
|
38
|
+
*/
|
|
39
|
+
function copyFileSync(source, destination) {
|
|
40
|
+
const src = source instanceof URL ? fileURLToPath(source) : source;
|
|
41
|
+
const dest = destination instanceof URL ? fileURLToPath(destination) : destination;
|
|
42
|
+
if (!hasFileExtension(dest)) {
|
|
43
|
+
if (!existsSync$1(resolveParentPath(dest))) createDirectorySync(resolveParentPath(dest));
|
|
44
|
+
} else if (!existsSync$1(findFilePath(dest))) createDirectorySync(findFilePath(dest));
|
|
45
|
+
if (isString(src) && existsSync$1(src)) return copyFileSync$1(src, dest);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Copy files from one location to another
|
|
49
|
+
*
|
|
50
|
+
* @param source - The source location, this can be a file, directory, URL, or glob pattern
|
|
51
|
+
* @param destination - The destination location
|
|
52
|
+
* @returns An indicator specifying if the copy was successful
|
|
53
|
+
*/
|
|
54
|
+
async function copyFiles(source, destination) {
|
|
55
|
+
const src = source instanceof URL ? fileURLToPath(source) : source;
|
|
56
|
+
const dest = destination instanceof URL ? fileURLToPath(destination) : destination;
|
|
57
|
+
if (isString(src) && isFile(src)) return copyFile(src, dest);
|
|
58
|
+
return Promise.all((await listFiles(src)).map(async (entryPath) => {
|
|
59
|
+
const destFile = joinPaths(dest, replacePath(entryPath, isString(src) ? stripStars(src) : src.input));
|
|
60
|
+
if (isDirectory(entryPath)) await copyFiles(entryPath, destFile);
|
|
61
|
+
else await copyFile(entryPath, destFile);
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Synchronously copy files from one location to another
|
|
66
|
+
*
|
|
67
|
+
* @param source - The source location, this can be a file, directory, URL, or glob pattern
|
|
68
|
+
* @param destination - The destination location
|
|
69
|
+
* @returns An indicator specifying if the copy was successful
|
|
70
|
+
*/
|
|
71
|
+
function copyFilesSync(source, destination) {
|
|
72
|
+
const src = source instanceof URL ? fileURLToPath(source) : source;
|
|
73
|
+
const dest = destination instanceof URL ? fileURLToPath(destination) : destination;
|
|
74
|
+
if (isString(src) && isFile(src)) return copyFileSync(src, dest);
|
|
75
|
+
return listFilesSync(src).map((entryPath) => {
|
|
76
|
+
const destFile = joinPaths(dest, replacePath(entryPath, isString(src) ? stripStars(src) : src.input));
|
|
77
|
+
if (isDirectory(entryPath)) copyFilesSync(entryPath, destFile);
|
|
78
|
+
else copyFileSync(entryPath, destFile);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { copyFile, copyFileSync, copyFiles, copyFilesSync };
|
|
2
84
|
//# sourceMappingURL=copy-file.mjs.map
|
package/dist/copy-file.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-file.mjs","names":["existsSync","cpf","cpfSync"],"sources":["../src/copy-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { stripStars } from \"@stryke/path/correct-path\";\nimport { findFilePath, hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { isString } from \"@stryke/type-checks\";\nimport type { AssetGlob } from \"@stryke/types/file\";\nimport { fileURLToPath } from \"mlly\";\nimport { copyFileSync as cpfSync } from \"node:fs\";\nimport { copyFile as cpf } from \"node:fs/promises\";\nimport { existsSync } from \"./exists\";\nimport { createDirectory, createDirectorySync } from \"./helpers\";\nimport { isDirectory, isFile } from \"./is-file\";\nimport { listFiles, listFilesSync } from \"./list-files\";\n\n/**\n * Copy a file from one location to another\n *\n * @param source - The file to copy, this can be a file, directory, URL, or glob pattern\n * @param destination - The destination location\n * @returns An indicator specifying if the copy was successful\n */\nexport async function copyFile(\n source: string | URL,\n destination: string | URL\n) {\n const src = source instanceof URL ? fileURLToPath(source) : source;\n const dest =\n destination instanceof URL ? fileURLToPath(destination) : destination;\n\n if (!hasFileExtension(dest)) {\n if (!existsSync(resolveParentPath(dest))) {\n await createDirectory(resolveParentPath(dest));\n }\n } else if (!existsSync(findFilePath(dest))) {\n await createDirectory(findFilePath(dest));\n }\n\n if (isString(src) && existsSync(src)) {\n return cpf(src, dest);\n }\n}\n\n/**\n * Synchronously copy a file from one location to another\n *\n * @param source - The file to copy, this can be a file, directory, URL, or glob pattern\n * @param destination - The destination location\n * @returns An indicator specifying if the copy was successful\n */\nexport function copyFileSync(source: string | URL, destination: string | URL) {\n const src = source instanceof URL ? fileURLToPath(source) : source;\n const dest =\n destination instanceof URL ? fileURLToPath(destination) : destination;\n\n if (!hasFileExtension(dest)) {\n if (!existsSync(resolveParentPath(dest))) {\n createDirectorySync(resolveParentPath(dest));\n }\n } else if (!existsSync(findFilePath(dest))) {\n createDirectorySync(findFilePath(dest));\n }\n\n if (isString(src) && existsSync(src)) {\n return cpfSync(src, dest);\n }\n}\n\n/**\n * Copy files from one location to another\n *\n * @param source - The source location, this can be a file, directory, URL, or glob pattern\n * @param destination - The destination location\n * @returns An indicator specifying if the copy was successful\n */\nexport async function copyFiles(\n source: string | URL | Omit<AssetGlob, \"output\">,\n destination: string | URL\n) {\n const src = source instanceof URL ? fileURLToPath(source) : source;\n const dest =\n destination instanceof URL ? fileURLToPath(destination) : destination;\n\n if (isString(src) && isFile(src)) {\n return copyFile(src, dest);\n }\n\n return Promise.all(\n (await listFiles(src)).map(async entryPath => {\n const destFile = joinPaths(\n dest,\n replacePath(entryPath, isString(src) ? stripStars(src) : src.input)\n );\n\n if (isDirectory(entryPath)) {\n await copyFiles(entryPath, destFile);\n } else {\n await copyFile(entryPath, destFile);\n }\n })\n );\n}\n\n/**\n * Synchronously copy files from one location to another\n *\n * @param source - The source location, this can be a file, directory, URL, or glob pattern\n * @param destination - The destination location\n * @returns An indicator specifying if the copy was successful\n */\nexport function copyFilesSync(\n source: string | URL | Omit<AssetGlob, \"output\">,\n destination: string | URL\n) {\n const src = source instanceof URL ? fileURLToPath(source) : source;\n const dest =\n destination instanceof URL ? fileURLToPath(destination) : destination;\n\n if (isString(src) && isFile(src)) {\n return copyFileSync(src, dest);\n }\n\n return listFilesSync(src).map(entryPath => {\n const destFile = joinPaths(\n dest,\n replacePath(entryPath, isString(src) ? stripStars(src) : src.input)\n );\n\n if (isDirectory(entryPath)) {\n copyFilesSync(entryPath, destFile);\n } else {\n copyFileSync(entryPath, destFile);\n }\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"copy-file.mjs","names":["existsSync","cpf","cpfSync"],"sources":["../src/copy-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { stripStars } from \"@stryke/path/correct-path\";\nimport { findFilePath, hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { isString } from \"@stryke/type-checks\";\nimport type { AssetGlob } from \"@stryke/types/file\";\nimport { fileURLToPath } from \"mlly\";\nimport { copyFileSync as cpfSync } from \"node:fs\";\nimport { copyFile as cpf } from \"node:fs/promises\";\nimport { existsSync } from \"./exists\";\nimport { createDirectory, createDirectorySync } from \"./helpers\";\nimport { isDirectory, isFile } from \"./is-file\";\nimport { listFiles, listFilesSync } from \"./list-files\";\n\n/**\n * Copy a file from one location to another\n *\n * @param source - The file to copy, this can be a file, directory, URL, or glob pattern\n * @param destination - The destination location\n * @returns An indicator specifying if the copy was successful\n */\nexport async function copyFile(\n source: string | URL,\n destination: string | URL\n) {\n const src = source instanceof URL ? fileURLToPath(source) : source;\n const dest =\n destination instanceof URL ? fileURLToPath(destination) : destination;\n\n if (!hasFileExtension(dest)) {\n if (!existsSync(resolveParentPath(dest))) {\n await createDirectory(resolveParentPath(dest));\n }\n } else if (!existsSync(findFilePath(dest))) {\n await createDirectory(findFilePath(dest));\n }\n\n if (isString(src) && existsSync(src)) {\n return cpf(src, dest);\n }\n}\n\n/**\n * Synchronously copy a file from one location to another\n *\n * @param source - The file to copy, this can be a file, directory, URL, or glob pattern\n * @param destination - The destination location\n * @returns An indicator specifying if the copy was successful\n */\nexport function copyFileSync(source: string | URL, destination: string | URL) {\n const src = source instanceof URL ? fileURLToPath(source) : source;\n const dest =\n destination instanceof URL ? fileURLToPath(destination) : destination;\n\n if (!hasFileExtension(dest)) {\n if (!existsSync(resolveParentPath(dest))) {\n createDirectorySync(resolveParentPath(dest));\n }\n } else if (!existsSync(findFilePath(dest))) {\n createDirectorySync(findFilePath(dest));\n }\n\n if (isString(src) && existsSync(src)) {\n return cpfSync(src, dest);\n }\n}\n\n/**\n * Copy files from one location to another\n *\n * @param source - The source location, this can be a file, directory, URL, or glob pattern\n * @param destination - The destination location\n * @returns An indicator specifying if the copy was successful\n */\nexport async function copyFiles(\n source: string | URL | Omit<AssetGlob, \"output\">,\n destination: string | URL\n) {\n const src = source instanceof URL ? fileURLToPath(source) : source;\n const dest =\n destination instanceof URL ? fileURLToPath(destination) : destination;\n\n if (isString(src) && isFile(src)) {\n return copyFile(src, dest);\n }\n\n return Promise.all(\n (await listFiles(src)).map(async entryPath => {\n const destFile = joinPaths(\n dest,\n replacePath(entryPath, isString(src) ? stripStars(src) : src.input)\n );\n\n if (isDirectory(entryPath)) {\n await copyFiles(entryPath, destFile);\n } else {\n await copyFile(entryPath, destFile);\n }\n })\n );\n}\n\n/**\n * Synchronously copy files from one location to another\n *\n * @param source - The source location, this can be a file, directory, URL, or glob pattern\n * @param destination - The destination location\n * @returns An indicator specifying if the copy was successful\n */\nexport function copyFilesSync(\n source: string | URL | Omit<AssetGlob, \"output\">,\n destination: string | URL\n) {\n const src = source instanceof URL ? fileURLToPath(source) : source;\n const dest =\n destination instanceof URL ? fileURLToPath(destination) : destination;\n\n if (isString(src) && isFile(src)) {\n return copyFileSync(src, dest);\n }\n\n return listFilesSync(src).map(entryPath => {\n const destFile = joinPaths(\n dest,\n replacePath(entryPath, isString(src) ? stripStars(src) : src.input)\n );\n\n if (isDirectory(entryPath)) {\n copyFilesSync(entryPath, destFile);\n } else {\n copyFileSync(entryPath, destFile);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwCA,eAAsB,SACpB,QACA,aACA;CACA,MAAM,MAAM,kBAAkB,MAAM,cAAc,OAAO,GAAG;CAC5D,MAAM,OACJ,uBAAuB,MAAM,cAAc,YAAY,GAAG;AAE5D,KAAI,CAAC,iBAAiB,KAAK,EACzB;MAAI,CAACA,aAAW,kBAAkB,KAAK,CAAC,CACtC,OAAM,gBAAgB,kBAAkB,KAAK,CAAC;YAEvC,CAACA,aAAW,aAAa,KAAK,CAAC,CACxC,OAAM,gBAAgB,aAAa,KAAK,CAAC;AAG3C,KAAI,SAAS,IAAI,IAAIA,aAAW,IAAI,CAClC,QAAOC,WAAI,KAAK,KAAK;;;;;;;;;AAWzB,SAAgB,aAAa,QAAsB,aAA2B;CAC5E,MAAM,MAAM,kBAAkB,MAAM,cAAc,OAAO,GAAG;CAC5D,MAAM,OACJ,uBAAuB,MAAM,cAAc,YAAY,GAAG;AAE5D,KAAI,CAAC,iBAAiB,KAAK,EACzB;MAAI,CAACD,aAAW,kBAAkB,KAAK,CAAC,CACtC,qBAAoB,kBAAkB,KAAK,CAAC;YAErC,CAACA,aAAW,aAAa,KAAK,CAAC,CACxC,qBAAoB,aAAa,KAAK,CAAC;AAGzC,KAAI,SAAS,IAAI,IAAIA,aAAW,IAAI,CAClC,QAAOE,eAAQ,KAAK,KAAK;;;;;;;;;AAW7B,eAAsB,UACpB,QACA,aACA;CACA,MAAM,MAAM,kBAAkB,MAAM,cAAc,OAAO,GAAG;CAC5D,MAAM,OACJ,uBAAuB,MAAM,cAAc,YAAY,GAAG;AAE5D,KAAI,SAAS,IAAI,IAAI,OAAO,IAAI,CAC9B,QAAO,SAAS,KAAK,KAAK;AAG5B,QAAO,QAAQ,KACZ,MAAM,UAAU,IAAI,EAAE,IAAI,OAAM,cAAa;EAC5C,MAAM,WAAW,UACf,MACA,YAAY,WAAW,SAAS,IAAI,GAAG,WAAW,IAAI,GAAG,IAAI,MAAM,CACpE;AAED,MAAI,YAAY,UAAU,CACxB,OAAM,UAAU,WAAW,SAAS;MAEpC,OAAM,SAAS,WAAW,SAAS;GAErC,CACH;;;;;;;;;AAUH,SAAgB,cACd,QACA,aACA;CACA,MAAM,MAAM,kBAAkB,MAAM,cAAc,OAAO,GAAG;CAC5D,MAAM,OACJ,uBAAuB,MAAM,cAAc,YAAY,GAAG;AAE5D,KAAI,SAAS,IAAI,IAAI,OAAO,IAAI,CAC9B,QAAO,aAAa,KAAK,KAAK;AAGhC,QAAO,cAAc,IAAI,CAAC,KAAI,cAAa;EACzC,MAAM,WAAW,UACf,MACA,YAAY,WAAW,SAAS,IAAI,GAAG,WAAW,IAAI,GAAG,IAAI,MAAM,CACpE;AAED,MAAI,YAAY,UAAU,CACxB,eAAc,WAAW,SAAS;MAElC,cAAa,WAAW,SAAS;GAEnC"}
|
package/dist/exists.cjs
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let node_fs = require("node:fs");
|
|
3
|
+
let node_fs_promises = require("node:fs/promises");
|
|
4
|
+
|
|
5
|
+
//#region src/exists.ts
|
|
6
|
+
/**
|
|
7
|
+
* Check if a file exists
|
|
8
|
+
*
|
|
9
|
+
* @param filePath - The file path to check
|
|
10
|
+
* @returns An indicator specifying if the file exists
|
|
11
|
+
*/
|
|
12
|
+
function existsSync(filePath) {
|
|
13
|
+
return (0, node_fs.existsSync)(filePath);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if a file exists
|
|
17
|
+
*
|
|
18
|
+
* @param filePath - The file path to check
|
|
19
|
+
* @returns An indicator specifying if the file exists
|
|
20
|
+
*/
|
|
21
|
+
async function exists(filePath) {
|
|
22
|
+
return (0, node_fs_promises.access)(filePath, node_fs_promises.constants.F_OK).then(() => true).catch(() => false);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.exists = exists;
|
|
27
|
+
exports.existsSync = existsSync;
|
package/dist/exists.mjs
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import { existsSync as existsSync$1 } from "node:fs";
|
|
2
|
+
import { access, constants as constants$1 } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
//#region src/exists.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if a file exists
|
|
7
|
+
*
|
|
8
|
+
* @param filePath - The file path to check
|
|
9
|
+
* @returns An indicator specifying if the file exists
|
|
10
|
+
*/
|
|
11
|
+
function existsSync(filePath) {
|
|
12
|
+
return existsSync$1(filePath);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if a file exists
|
|
16
|
+
*
|
|
17
|
+
* @param filePath - The file path to check
|
|
18
|
+
* @returns An indicator specifying if the file exists
|
|
19
|
+
*/
|
|
20
|
+
async function exists(filePath) {
|
|
21
|
+
return access(filePath, constants$1.F_OK).then(() => true).catch(() => false);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { exists, existsSync };
|
|
2
26
|
//# sourceMappingURL=exists.mjs.map
|
package/dist/exists.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exists.mjs","names":["existsSyncFs","constants"],"sources":["../src/exists.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { existsSync as existsSyncFs } from \"node:fs\";\nimport { access, constants } from \"node:fs/promises\";\n\n/**\n * Check if a file exists\n *\n * @param filePath - The file path to check\n * @returns An indicator specifying if the file exists\n */\nexport function existsSync(filePath: string): boolean {\n return existsSyncFs(filePath);\n}\n\n/**\n * Check if a file exists\n *\n * @param filePath - The file path to check\n * @returns An indicator specifying if the file exists\n */\nexport async function exists(filePath: string): Promise<boolean> {\n return access(filePath, constants.F_OK)\n .then(() => true)\n .catch(() => false);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"exists.mjs","names":["existsSyncFs","constants"],"sources":["../src/exists.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { existsSync as existsSyncFs } from \"node:fs\";\nimport { access, constants } from \"node:fs/promises\";\n\n/**\n * Check if a file exists\n *\n * @param filePath - The file path to check\n * @returns An indicator specifying if the file exists\n */\nexport function existsSync(filePath: string): boolean {\n return existsSyncFs(filePath);\n}\n\n/**\n * Check if a file exists\n *\n * @param filePath - The file path to check\n * @returns An indicator specifying if the file exists\n */\nexport async function exists(filePath: string): Promise<boolean> {\n return access(filePath, constants.F_OK)\n .then(() => true)\n .catch(() => false);\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,WAAW,UAA2B;AACpD,QAAOA,aAAa,SAAS;;;;;;;;AAS/B,eAAsB,OAAO,UAAoC;AAC/D,QAAO,OAAO,UAAUC,YAAU,KAAK,CACpC,WAAW,KAAK,CAChB,YAAY,MAAM"}
|