diff --git a/.changeset/nasty-keys-act.md b/.changeset/nasty-keys-act.md new file mode 100644 index 0000000000..4ab747df09 --- /dev/null +++ b/.changeset/nasty-keys-act.md @@ -0,0 +1,5 @@ +--- +'@commercetools-frontend/mc-scripts': patch +--- + +Fix problem with file name in Windows when name contains characters like `:`. diff --git a/packages/mc-scripts/src/bin/cli.js b/packages/mc-scripts/src/bin/cli.js index 292bebf577..d19f55984b 100755 --- a/packages/mc-scripts/src/bin/cli.js +++ b/packages/mc-scripts/src/bin/cli.js @@ -119,7 +119,12 @@ const applicationDirectory = fs.realpathSync(process.cwd()); // Get specific flag for this command. const commandArgs = getArgsForCommand(['dry-run']); - proxyCommand(command, { commandArgs }); + proxyCommand(command, { + commandArgs, + // File names with `:` cause issues in Windows, therefore the file name is + // different from the command name. + fileName: 'config-sync', + }); break; } default: @@ -145,7 +150,7 @@ function getArgsForCommand(allowedFlags = []) { }, []); } -function proxyCommand(fileName, { commandArgs, noExit } = {}) { +function proxyCommand(commandName, { commandArgs, fileName, noExit } = {}) { // Load dotenv files into the process environment. // This is essentially what `dotenv-cli` does, but it's now built into this CLI. loadDotEnvFiles(flags); @@ -153,7 +158,9 @@ function proxyCommand(fileName, { commandArgs, noExit } = {}) { // Spawn the actual command. const result = spawn.sync( 'node', - [require.resolve(`../commands/${fileName}`)].concat(commandArgs), + [require.resolve(`../commands/${fileName || commandName}`)].concat( + commandArgs + ), { stdio: 'inherit' } ); @@ -162,13 +169,13 @@ function proxyCommand(fileName, { commandArgs, noExit } = {}) { switch (result.signal) { case 'SIGKILL': { console.log( - `The command ${fileName} failed because the process exited too early. This probably means the system ran out of memory or someone called "kill -9" on the process.` + `The command ${commandName} failed because the process exited too early. This probably means the system ran out of memory or someone called "kill -9" on the process.` ); break; } case 'SIGTERM': { console.log( - `The command ${fileName} failed because the process exited too early. Someone might have called "kill" or "killall", or the system could be shutting down.` + `The command ${commandName} failed because the process exited too early. Someone might have called "kill" or "killall", or the system could be shutting down.` ); break; } diff --git a/packages/mc-scripts/src/commands/config:sync.js b/packages/mc-scripts/src/commands/config-sync.js similarity index 100% rename from packages/mc-scripts/src/commands/config:sync.js rename to packages/mc-scripts/src/commands/config-sync.js