@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.
Files changed (191) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -1
  3. package/dist/buffer.cjs +60 -1
  4. package/dist/buffer.mjs +56 -1
  5. package/dist/buffer.mjs.map +1 -1
  6. package/dist/chmod-x.cjs +93 -1
  7. package/dist/chmod-x.d.cts.map +1 -1
  8. package/dist/chmod-x.mjs +87 -1
  9. package/dist/chmod-x.mjs.map +1 -1
  10. package/dist/command-exists.cjs +102 -1
  11. package/dist/command-exists.mjs +100 -1
  12. package/dist/command-exists.mjs.map +1 -1
  13. package/dist/compress.cjs +29 -1
  14. package/dist/compress.mjs +28 -1
  15. package/dist/compress.mjs.map +1 -1
  16. package/dist/constants.mjs +1 -1
  17. package/dist/convert/src/array-buffer-to-string.cjs +19 -1
  18. package/dist/convert/src/array-buffer-to-string.mjs +18 -1
  19. package/dist/convert/src/array-buffer-to-string.mjs.map +1 -1
  20. package/dist/convert/src/to-array.cjs +15 -1
  21. package/dist/convert/src/to-array.mjs +14 -1
  22. package/dist/convert/src/to-array.mjs.map +1 -1
  23. package/dist/convert/src/uint8-array-to-string.cjs +15 -1
  24. package/dist/convert/src/uint8-array-to-string.mjs +15 -1
  25. package/dist/convert/src/uint8-array-to-string.mjs.map +1 -1
  26. package/dist/copy-file.cjs +87 -1
  27. package/dist/copy-file.mjs +83 -1
  28. package/dist/copy-file.mjs.map +1 -1
  29. package/dist/exists.cjs +27 -1
  30. package/dist/exists.mjs +25 -1
  31. package/dist/exists.mjs.map +1 -1
  32. package/dist/get-parent-path.cjs +35 -1
  33. package/dist/get-parent-path.mjs +34 -1
  34. package/dist/get-parent-path.mjs.map +1 -1
  35. package/dist/get-workspace-root.cjs +158 -1
  36. package/dist/get-workspace-root.mjs +150 -1
  37. package/dist/get-workspace-root.mjs.map +1 -1
  38. package/dist/helpers/src/get-unique.cjs +14 -1
  39. package/dist/helpers/src/get-unique.mjs +13 -1
  40. package/dist/helpers/src/get-unique.mjs.map +1 -1
  41. package/dist/helpers.cjs +83 -1
  42. package/dist/helpers.mjs +77 -1
  43. package/dist/helpers.mjs.map +1 -1
  44. package/dist/index.cjs +122 -1
  45. package/dist/index.mjs +25 -1
  46. package/dist/install.cjs +35 -1
  47. package/dist/install.mjs +33 -1
  48. package/dist/install.mjs.map +1 -1
  49. package/dist/is-file.cjs +51 -1
  50. package/dist/is-file.mjs +47 -1
  51. package/dist/is-file.mjs.map +1 -1
  52. package/dist/json/src/storm-json.cjs +117 -1
  53. package/dist/json/src/storm-json.mjs +115 -1
  54. package/dist/json/src/storm-json.mjs.map +1 -1
  55. package/dist/json/src/utils/code-frames.cjs +77 -3
  56. package/dist/json/src/utils/code-frames.mjs +76 -3
  57. package/dist/json/src/utils/code-frames.mjs.map +1 -1
  58. package/dist/json/src/utils/parse-error.cjs +34 -1
  59. package/dist/json/src/utils/parse-error.mjs +33 -1
  60. package/dist/json/src/utils/parse-error.mjs.map +1 -1
  61. package/dist/json/src/utils/parse.cjs +45 -1
  62. package/dist/json/src/utils/parse.mjs +45 -1
  63. package/dist/json/src/utils/parse.mjs.map +1 -1
  64. package/dist/json/src/utils/stringify.cjs +67 -1
  65. package/dist/json/src/utils/stringify.mjs +67 -1
  66. package/dist/json/src/utils/stringify.mjs.map +1 -1
  67. package/dist/json/src/utils/strip-comments.cjs +86 -4
  68. package/dist/json/src/utils/strip-comments.mjs +86 -4
  69. package/dist/json/src/utils/strip-comments.mjs.map +1 -1
  70. package/dist/json.cjs +74 -1
  71. package/dist/json.mjs +71 -1
  72. package/dist/json.mjs.map +1 -1
  73. package/dist/list-files.cjs +86 -1
  74. package/dist/list-files.mjs +79 -1
  75. package/dist/list-files.mjs.map +1 -1
  76. package/dist/package-fns.cjs +148 -1
  77. package/dist/package-fns.mjs +141 -1
  78. package/dist/package-fns.mjs.map +1 -1
  79. package/dist/path/src/append.cjs +57 -1
  80. package/dist/path/src/append.mjs +56 -1
  81. package/dist/path/src/append.mjs.map +1 -1
  82. package/dist/path/src/correct-path.cjs +138 -1
  83. package/dist/path/src/correct-path.mjs +134 -1
  84. package/dist/path/src/correct-path.mjs.map +1 -1
  85. package/dist/path/src/cwd.cjs +17 -1
  86. package/dist/path/src/cwd.mjs +16 -1
  87. package/dist/path/src/cwd.mjs.map +1 -1
  88. package/dist/path/src/file-path-fns.cjs +169 -1
  89. package/dist/path/src/file-path-fns.mjs +164 -1
  90. package/dist/path/src/file-path-fns.mjs.map +1 -1
  91. package/dist/path/src/is-parent-path.cjs +32 -1
  92. package/dist/path/src/is-parent-path.mjs +32 -1
  93. package/dist/path/src/is-parent-path.mjs.map +1 -1
  94. package/dist/path/src/is-root-dir.cjs +14 -1
  95. package/dist/path/src/is-root-dir.mjs +13 -1
  96. package/dist/path/src/is-root-dir.mjs.map +1 -1
  97. package/dist/path/src/is-type.cjs +68 -1
  98. package/dist/path/src/is-type.mjs +66 -1
  99. package/dist/path/src/is-type.mjs.map +1 -1
  100. package/dist/path/src/join-paths.cjs +106 -1
  101. package/dist/path/src/join-paths.mjs +106 -1
  102. package/dist/path/src/join-paths.mjs.map +1 -1
  103. package/dist/path/src/regex.cjs +18 -1
  104. package/dist/path/src/regex.mjs +11 -1
  105. package/dist/path/src/regex.mjs.map +1 -1
  106. package/dist/path/src/replace.cjs +24 -1
  107. package/dist/path/src/replace.mjs +24 -1
  108. package/dist/path/src/replace.mjs.map +1 -1
  109. package/dist/path/src/resolve-parent-path.cjs +18 -1
  110. package/dist/path/src/resolve-parent-path.mjs +18 -1
  111. package/dist/path/src/resolve-parent-path.mjs.map +1 -1
  112. package/dist/path/src/slash.cjs +15 -1
  113. package/dist/path/src/slash.mjs +14 -1
  114. package/dist/path/src/slash.mjs.map +1 -1
  115. package/dist/read-file.cjs +47 -1
  116. package/dist/read-file.mjs +43 -1
  117. package/dist/read-file.mjs.map +1 -1
  118. package/dist/registry.cjs +142 -1
  119. package/dist/registry.mjs +137 -1
  120. package/dist/registry.mjs.map +1 -1
  121. package/dist/remove-file.cjs +27 -1
  122. package/dist/remove-file.mjs +25 -1
  123. package/dist/remove-file.mjs.map +1 -1
  124. package/dist/resolve.cjs +228 -3
  125. package/dist/resolve.mjs +217 -3
  126. package/dist/resolve.mjs.map +1 -1
  127. package/dist/semver-fns.cjs +129 -1
  128. package/dist/semver-fns.mjs +119 -1
  129. package/dist/semver-fns.mjs.map +1 -1
  130. package/dist/string-format/src/package.cjs +92 -1
  131. package/dist/string-format/src/package.mjs +91 -1
  132. package/dist/string-format/src/package.mjs.map +1 -1
  133. package/dist/toml.cjs +66 -3
  134. package/dist/toml.mjs +61 -3
  135. package/dist/toml.mjs.map +1 -1
  136. package/dist/tsconfig.cjs +37 -1
  137. package/dist/tsconfig.mjs +35 -1
  138. package/dist/tsconfig.mjs.map +1 -1
  139. package/dist/type-checks/src/get-object-tag.cjs +15 -1
  140. package/dist/type-checks/src/get-object-tag.mjs +14 -1
  141. package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
  142. package/dist/type-checks/src/index.cjs +14 -1
  143. package/dist/type-checks/src/index.mjs +16 -1
  144. package/dist/type-checks/src/is-buffer.cjs +12 -1
  145. package/dist/type-checks/src/is-buffer.mjs +11 -1
  146. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  147. package/dist/type-checks/src/is-collection.cjs +1 -1
  148. package/dist/type-checks/src/is-collection.mjs +3 -1
  149. package/dist/type-checks/src/is-empty.cjs +20 -1
  150. package/dist/type-checks/src/is-empty.mjs +20 -1
  151. package/dist/type-checks/src/is-empty.mjs.map +1 -1
  152. package/dist/type-checks/src/is-error.cjs +29 -1
  153. package/dist/type-checks/src/is-error.mjs +29 -1
  154. package/dist/type-checks/src/is-error.mjs.map +1 -1
  155. package/dist/type-checks/src/is-null.cjs +12 -1
  156. package/dist/type-checks/src/is-null.mjs +11 -1
  157. package/dist/type-checks/src/is-null.mjs.map +1 -1
  158. package/dist/type-checks/src/is-number.cjs +18 -1
  159. package/dist/type-checks/src/is-number.mjs +17 -1
  160. package/dist/type-checks/src/is-number.mjs.map +1 -1
  161. package/dist/type-checks/src/is-object.cjs +19 -1
  162. package/dist/type-checks/src/is-object.mjs +19 -1
  163. package/dist/type-checks/src/is-object.mjs.map +1 -1
  164. package/dist/type-checks/src/is-plain-object.cjs +64 -1
  165. package/dist/type-checks/src/is-plain-object.mjs +63 -1
  166. package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
  167. package/dist/type-checks/src/is-set-string.cjs +20 -1
  168. package/dist/type-checks/src/is-set-string.mjs +20 -1
  169. package/dist/type-checks/src/is-set-string.mjs.map +1 -1
  170. package/dist/type-checks/src/is-set.cjs +19 -1
  171. package/dist/type-checks/src/is-set.mjs +19 -1
  172. package/dist/type-checks/src/is-set.mjs.map +1 -1
  173. package/dist/type-checks/src/is-string.cjs +12 -1
  174. package/dist/type-checks/src/is-string.mjs +11 -1
  175. package/dist/type-checks/src/is-string.mjs.map +1 -1
  176. package/dist/type-checks/src/is-undefined.cjs +8 -1
  177. package/dist/type-checks/src/is-undefined.mjs +7 -1
  178. package/dist/type-checks/src/is-undefined.mjs.map +1 -1
  179. package/dist/type-checks/src/type-detect.cjs +15 -1
  180. package/dist/type-checks/src/type-detect.mjs +16 -1
  181. package/dist/type-checks/src/type-detect.mjs.map +1 -1
  182. package/dist/types/src/base.cjs +6 -1
  183. package/dist/types/src/base.mjs +5 -1
  184. package/dist/types/src/base.mjs.map +1 -1
  185. package/dist/write-file.cjs +40 -1
  186. package/dist/write-file.mjs +38 -1
  187. package/dist/write-file.mjs.map +1 -1
  188. package/dist/yaml.cjs +29 -1
  189. package/dist/yaml.mjs +27 -1
  190. package/dist/yaml.mjs.map +1 -1
  191. 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":"wMAuBA,MAAM,EAAiB,QAAQ,UAAY,QAE3C,eAAe,EAAc,EAAqB,CAChD,GAAI,CAEF,OADA,MAAM,EAAO,EAAaA,EAAU,KAAK,CAClC,QAEG,CACV,MAAO,IAIX,SAAS,EAAkB,EAAqB,CAC9C,GAAI,CAEF,OADA,EAAW,EAAaA,EAAU,KAAK,CAChC,QAEG,CACV,MAAO,IAIX,eAAe,EAAgB,EAAqB,CAClD,OAAO,EAAO,EAAaA,EAAU,KAAOA,EAAU,KAAK,CAG7D,SAAS,EAAoB,EAAqB,CAChD,GAAI,CAEF,OADA,EAAW,EAAaA,EAAU,KAAOA,EAAU,KAAK,CACjD,QAEG,CACV,MAAO,IAIX,eAAe,EACb,EACA,EACA,CACe,MAAM,EAAc,EAAY,GAG7C,EACE,cAAc,EAAmB,6BACb,EAAmB,aACxC,CAED,MAAM,EAAgB,EAAY,EAItC,eAAe,EACb,EACA,EACA,CAEK,qDAAqD,KAAK,EAAY,EAI3E,EAAK,SAAS,IAAqB,CAGrC,SAAS,EACP,EACA,EACS,CACT,GAAI,EAAkB,EAAY,CAChC,GAAI,CAMF,MAAO,CAAC,CALO,EACb,cAAc,EAAmB,6BACb,EAAmB,aACxC,MAIS,CACV,MAAO,GAGX,OAAO,EAAoB,EAAY,CAGzC,SAAS,EACP,EACA,EACA,CAEA,GAAI,CAAC,qDAAqD,KAAK,EAAY,CACzE,MAAO,GAET,GAAI,CAGF,MAAO,CAAC,CAFO,EAAS,SAAS,IAAsB,CAAE,MAAO,EAAE,CAAE,CAAC,MAI3D,CACV,MAAO,IAIX,SAAS,EAAW,EAAW,CAO7B,MANI,YAAY,KAAK,EAAE,GACrB,EAAI,IAAI,EAAE,QAAQ,KAAM,QAAQ,CAAC,GACjC,EAAI,EACD,QAAQ,YAAa,GAAG,CACxB,QAAQ,SAAU,MAAM,EAEtB,EAGT,MAAM,EAAqB,GACN,KAAK,KAAK,EAAE,CAEtB,IAAI,EAAQ,EAAE,CAAC,GAAG,EAAS,EAAE,CAAC,GAEhC,IAAI,EAAE,GAWf,eAAsB,EAAc,EAAqB,CACvD,IAAM,EAAqB,EAAW,EAAY,CAQhD,OANE,OAAO,QAAY,IACd,EAAc,EAAY,CAE/B,EACK,EAAqB,EAAa,EAAmB,CAErD,EAAkB,EAAa,EAAmB,CAY7D,SAAgB,EAAkB,EAA8B,CAO5D,OANE,EACK,EACL,EACA,EAAkB,EAAY,CAC/B,CAEM,EAAsB,EAAa,EAAW,EAAY,CAAC"}
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 e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./path/src/join-paths.cjs`),n=require(`./path/src/file-path-fns.cjs`),r=require(`./path/src/resolve-parent-path.cjs`),i=require(`./convert/src/uint8-array-to-string.cjs`),a=require(`./is-file.cjs`),o=require(`./list-files.cjs`),s=require(`./read-file.cjs`),c=require(`./write-file.cjs`);let l=require(`nanotar`);async function u(e,u){let d=await o.listFiles(a.isDirectory(e)?t.joinPaths(e,`**/*`):e,u),f=await(0,l.createTarGzip)(await Promise.all(d.map(async e=>({name:e,data:await s.readFileIfExisting(e)}))),{attrs:{group:`storm-software`}});return c.writeFile(u?.destination?a.isDirectory(u.destination)?t.joinPaths(u.destination,`${new Date().getTime()}.tar.gz`):u.destination:a.isDirectory(e)?`${t.joinPaths(r.resolveParentPath(e),n.findFolderName(e))}.tar.gz`:e,i.uint8ArrayToString(f))}exports.compressDirectory=u;
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 as e}from"./path/src/join-paths.mjs";import{findFolderName as t}from"./path/src/file-path-fns.mjs";import{resolveParentPath as n}from"./path/src/resolve-parent-path.mjs";import{uint8ArrayToString as r}from"./convert/src/uint8-array-to-string.mjs";import{isDirectory as i}from"./is-file.mjs";import{listFiles as a}from"./list-files.mjs";import{readFileIfExisting as o}from"./read-file.mjs";import{writeFile as s}from"./write-file.mjs";import{createTarGzip as c}from"nanotar";async function l(l,u){let d=await a(i(l)?e(l,`**/*`):l,u),f=await c(await Promise.all(d.map(async e=>({name:e,data:await o(e)}))),{attrs:{group:`storm-software`}});return s(u?.destination?i(u.destination)?e(u.destination,`${new Date().getTime()}.tar.gz`):u.destination:i(l)?`${e(n(l),t(l))}.tar.gz`:l,r(f))}export{l as compressDirectory};
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
@@ -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":"2eAsCA,eAAsB,EACpB,EACA,EACe,CACf,IAAM,EAAQ,MAAM,EAClB,EAAY,EAAU,CAAG,EAAU,EAAW,OAAO,CAAG,EACxD,EACD,CACK,EAAO,MAAM,EACjB,MAAM,QAAQ,IACZ,EAAM,IAAI,KAAM,KAAS,CACvB,KAAM,EACN,KAAM,MAAM,EAAmB,EAAK,CACrC,EAAE,CACJ,CACD,CACE,MAAO,CAAE,MAAO,iBAAkB,CACnC,CACF,CAED,OAAO,EACL,GAAS,YACL,EAAY,EAAQ,YAAY,CAC9B,EAAU,EAAQ,YAAa,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,CAChE,EAAQ,YACV,EAAY,EAAU,CACpB,GAAG,EAAU,EAAkB,EAAU,CAAE,EAAe,EAAU,CAAC,CAAC,SACtE,EACN,EAAmB,EAAK,CACzB"}
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"}
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1,19 @@
1
- function e(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=t.byteLength;if(n<65535)return String.fromCharCode.apply(null,t);let r=``;for(let e=0;e<n;e++)r+=String.fromCharCode(t[e]);return r}exports.arrayBufferToString=e;
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
- function e(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=t.byteLength;if(n<65535)return String.fromCharCode.apply(null,t);let r=``;for(let e=0;e<n;e++)r+=String.fromCharCode(t[e]);return r}export{e as arrayBufferToString};
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,EACd,EACQ,CACR,IAAM,EACJ,aAAkB,WACd,EACA,IAAI,WAAW,EAA0B,CACzC,EAAM,EAAM,WAClB,GAAI,EAAM,MACR,OAAO,OAAO,aAAa,MAAM,KAAM,EAA6B,CAEtE,IAAI,EAAS,GACb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,IACvB,GAAU,OAAO,aAAa,EAAM,GAAI,CAE1C,OAAO"}
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
- function e(e){return e??=[],Array.isArray(e)?e:[e]}exports.toArray=e;
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
- function e(e){return e??=[],Array.isArray(e)?e:[e]}export{e as toArray};
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,EAAW,EAA0C,CAEnE,MADA,KAAiB,EAAE,CACZ,MAAM,QAAQ,EAAM,CAAG,EAAQ,CAAC,EAAM"}
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 e=require(`./array-buffer-to-string.cjs`);function t(t){return btoa(e.arrayBufferToString(t))}exports.uint8ArrayToString=t;
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 as e}from"./array-buffer-to-string.mjs";function t(t){return btoa(e(t))}export{t as uint8ArrayToString};
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":"mEA0BA,SAAgB,EAAmB,EAA4B,CAC7D,OAAO,KAAK,EAAoB,EAAO,CAAC"}
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"}
@@ -1 +1,87 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./path/src/join-paths.cjs`),n=require(`./path/src/correct-path.cjs`),r=require(`./type-checks/src/is-string.cjs`),i=require(`./path/src/file-path-fns.cjs`),a=require(`./path/src/replace.cjs`),o=require(`./path/src/resolve-parent-path.cjs`),s=require(`./exists.cjs`),c=require(`./helpers.cjs`),l=require(`./is-file.cjs`);require(`./type-checks/src/index.cjs`);const u=require(`./list-files.cjs`);let d=require(`node:fs`),f=require(`node:fs/promises`),p=require(`mlly`);async function m(e,t){let n=e instanceof URL?(0,p.fileURLToPath)(e):e,a=t instanceof URL?(0,p.fileURLToPath)(t):t;if(i.hasFileExtension(a)?s.existsSync(i.findFilePath(a))||await c.createDirectory(i.findFilePath(a)):s.existsSync(o.resolveParentPath(a))||await c.createDirectory(o.resolveParentPath(a)),r.isString(n)&&s.existsSync(n))return(0,f.copyFile)(n,a)}function h(e,t){let n=e instanceof URL?(0,p.fileURLToPath)(e):e,a=t instanceof URL?(0,p.fileURLToPath)(t):t;if(i.hasFileExtension(a)?s.existsSync(i.findFilePath(a))||c.createDirectorySync(i.findFilePath(a)):s.existsSync(o.resolveParentPath(a))||c.createDirectorySync(o.resolveParentPath(a)),r.isString(n)&&s.existsSync(n))return(0,d.copyFileSync)(n,a)}async function g(e,i){let o=e instanceof URL?(0,p.fileURLToPath)(e):e,s=i instanceof URL?(0,p.fileURLToPath)(i):i;return r.isString(o)&&l.isFile(o)?m(o,s):Promise.all((await u.listFiles(o)).map(async e=>{let i=t.joinPaths(s,a.replacePath(e,r.isString(o)?n.stripStars(o):o.input));l.isDirectory(e)?await g(e,i):await m(e,i)}))}function _(e,i){let o=e instanceof URL?(0,p.fileURLToPath)(e):e,s=i instanceof URL?(0,p.fileURLToPath)(i):i;return r.isString(o)&&l.isFile(o)?h(o,s):u.listFilesSync(o).map(e=>{let i=t.joinPaths(s,a.replacePath(e,r.isString(o)?n.stripStars(o):o.input));l.isDirectory(e)?_(e,i):h(e,i)})}exports.copyFile=m,exports.copyFileSync=h,exports.copyFiles=g,exports.copyFilesSync=_;
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;
@@ -1,2 +1,84 @@
1
- import{joinPaths as e}from"./path/src/join-paths.mjs";import{stripStars as t}from"./path/src/correct-path.mjs";import{isString as n}from"./type-checks/src/is-string.mjs";import{findFilePath as r,hasFileExtension as i}from"./path/src/file-path-fns.mjs";import{replacePath as a}from"./path/src/replace.mjs";import{resolveParentPath as o}from"./path/src/resolve-parent-path.mjs";import{existsSync as s}from"./exists.mjs";import{createDirectory as c,createDirectorySync as l}from"./helpers.mjs";import{isDirectory as u,isFile as d}from"./is-file.mjs";import"./type-checks/src/index.mjs";import{listFiles as f,listFilesSync as p}from"./list-files.mjs";import{copyFileSync as m}from"node:fs";import{copyFile as h}from"node:fs/promises";import{fileURLToPath as g}from"mlly";async function _(e,t){let a=e instanceof URL?g(e):e,l=t instanceof URL?g(t):t;if(i(l)?s(r(l))||await c(r(l)):s(o(l))||await c(o(l)),n(a)&&s(a))return h(a,l)}function v(e,t){let a=e instanceof URL?g(e):e,c=t instanceof URL?g(t):t;if(i(c)?s(r(c))||l(r(c)):s(o(c))||l(o(c)),n(a)&&s(a))return m(a,c)}async function y(r,i){let o=r instanceof URL?g(r):r,s=i instanceof URL?g(i):i;return n(o)&&d(o)?_(o,s):Promise.all((await f(o)).map(async r=>{let i=e(s,a(r,n(o)?t(o):o.input));u(r)?await y(r,i):await _(r,i)}))}function b(r,i){let o=r instanceof URL?g(r):r,s=i instanceof URL?g(i):i;return n(o)&&d(o)?v(o,s):p(o).map(r=>{let i=e(s,a(r,n(o)?t(o):o.input));u(r)?b(r,i):v(r,i)})}export{_ as copyFile,v as copyFileSync,y as copyFiles,b as copyFilesSync};
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
@@ -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":"+vBAwCA,eAAsB,EACpB,EACA,EACA,CACA,IAAM,EAAM,aAAkB,IAAM,EAAc,EAAO,CAAG,EACtD,EACJ,aAAuB,IAAM,EAAc,EAAY,CAAG,EAU5D,GARK,EAAiB,EAAK,CAIfA,EAAW,EAAa,EAAK,CAAC,EACxC,MAAM,EAAgB,EAAa,EAAK,CAAC,CAJpCA,EAAW,EAAkB,EAAK,CAAC,EACtC,MAAM,EAAgB,EAAkB,EAAK,CAAC,CAM9C,EAAS,EAAI,EAAIA,EAAW,EAAI,CAClC,OAAOC,EAAI,EAAK,EAAK,CAWzB,SAAgB,EAAa,EAAsB,EAA2B,CAC5E,IAAM,EAAM,aAAkB,IAAM,EAAc,EAAO,CAAG,EACtD,EACJ,aAAuB,IAAM,EAAc,EAAY,CAAG,EAU5D,GARK,EAAiB,EAAK,CAIfD,EAAW,EAAa,EAAK,CAAC,EACxC,EAAoB,EAAa,EAAK,CAAC,CAJlCA,EAAW,EAAkB,EAAK,CAAC,EACtC,EAAoB,EAAkB,EAAK,CAAC,CAM5C,EAAS,EAAI,EAAIA,EAAW,EAAI,CAClC,OAAOE,EAAQ,EAAK,EAAK,CAW7B,eAAsB,EACpB,EACA,EACA,CACA,IAAM,EAAM,aAAkB,IAAM,EAAc,EAAO,CAAG,EACtD,EACJ,aAAuB,IAAM,EAAc,EAAY,CAAG,EAM5D,OAJI,EAAS,EAAI,EAAI,EAAO,EAAI,CACvB,EAAS,EAAK,EAAK,CAGrB,QAAQ,KACZ,MAAM,EAAU,EAAI,EAAE,IAAI,KAAM,IAAa,CAC5C,IAAM,EAAW,EACf,EACA,EAAY,EAAW,EAAS,EAAI,CAAG,EAAW,EAAI,CAAG,EAAI,MAAM,CACpE,CAEG,EAAY,EAAU,CACxB,MAAM,EAAU,EAAW,EAAS,CAEpC,MAAM,EAAS,EAAW,EAAS,EAErC,CACH,CAUH,SAAgB,EACd,EACA,EACA,CACA,IAAM,EAAM,aAAkB,IAAM,EAAc,EAAO,CAAG,EACtD,EACJ,aAAuB,IAAM,EAAc,EAAY,CAAG,EAM5D,OAJI,EAAS,EAAI,EAAI,EAAO,EAAI,CACvB,EAAa,EAAK,EAAK,CAGzB,EAAc,EAAI,CAAC,IAAI,GAAa,CACzC,IAAM,EAAW,EACf,EACA,EAAY,EAAW,EAAS,EAAI,CAAG,EAAW,EAAI,CAAG,EAAI,MAAM,CACpE,CAEG,EAAY,EAAU,CACxB,EAAc,EAAW,EAAS,CAElC,EAAa,EAAW,EAAS,EAEnC"}
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 e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`node:fs`),n=require(`node:fs/promises`);function r(e){return(0,t.existsSync)(e)}async function i(e){return(0,n.access)(e,n.constants.F_OK).then(()=>!0).catch(()=>!1)}exports.exists=i,exports.existsSync=r;
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 e}from"node:fs";import{access as t,constants as n}from"node:fs/promises";function r(t){return e(t)}async function i(e){return t(e,n.F_OK).then(()=>!0).catch(()=>!1)}export{i as exists,r as existsSync};
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
@@ -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":"8FA2BA,SAAgB,EAAW,EAA2B,CACpD,OAAOA,EAAa,EAAS,CAS/B,eAAsB,EAAO,EAAoC,CAC/D,OAAO,EAAO,EAAUC,EAAU,KAAK,CACpC,SAAW,GAAK,CAChB,UAAY,GAAM"}
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"}