From 633f945bf6f1277ad90a9f0f5613bdfb595853a5 Mon Sep 17 00:00:00 2001 From: Michael Tsang Date: Thu, 26 Sep 2024 12:36:32 +0100 Subject: [PATCH] fix errors when specifying zip path with spaces --- src/cli/OutputGTFSZipCommand.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cli/OutputGTFSZipCommand.ts b/src/cli/OutputGTFSZipCommand.ts index b1acd20a..02b51354 100644 --- a/src/cli/OutputGTFSZipCommand.ts +++ b/src/cli/OutputGTFSZipCommand.ts @@ -29,8 +29,12 @@ export class OutputGTFSZipCommand implements CLICommand { // when node tells you it's finished writing a file, it's lying. setTimeout(() => { console.log("Writing " + filename); - execSync(`zip -j ${filename} ${argv[3]}/*.txt`); + execSync(`zip -j '${escapeShellArg(filename)}' ${argv[3]}/*.txt`); }, 1000); } +} + +function escapeShellArg (arg) { + return `'${arg.replace(/'/g, `'\\''`)}'`; } \ No newline at end of file