| 221 | |
| 222 | // ./file-zip -mode 1 --file main.go --file file-zip --file 123 --file README.md --zipPath aaabb.zip |
| 223 | async function useZip(distZip: string, files: string[], code = "utf-8"): Promise<boolean> { |
| 224 | if (!files || files.length == 0) throw new Error(t("TXT_CODE_2038ec2c")); |
| 225 | const params = ["--mode=1", `--code=${code}`, `--zipPath=${path.basename(distZip)}`]; |
| 226 | files.forEach((v) => { |
| 227 | params.push(`--file=${path.basename(v)}`); |
| 228 | }); |
| 229 | logger.info( |
| 230 | `Function useZip(): Command: ${GOLANG_ZIP_PATH} ${params.join(" ")}, CWD: ${path.dirname( |
| 231 | distZip |
| 232 | )}` |
| 233 | ); |
| 234 | const subProcess = new ProcessWrapper( |
| 235 | GOLANG_ZIP_PATH, |
| 236 | params, |
| 237 | path.dirname(distZip), |
| 238 | ZIP_TIMEOUT_SECONDS, |
| 239 | code |
| 240 | ); |
| 241 | subProcess.setErrMsg(COMPRESS_ERROR_MSG); |
| 242 | return subProcess.start(); |
| 243 | } |