Skip to content

Commit

Permalink
elaborate on explanation for windows cmd.exe spawning workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj committed Nov 4, 2024
1 parent 4f41569 commit bcbc1fd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/cli-test/src/cli/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@ function getSpawnArguments(
if (process.platform === 'win32') {
// In windows, we actually spawn a command prompt and tell it to invoke the CLI command.
// The combination of windows and node's child_process spawning is complicated: on windows, child_process strips quotes from arguments. This makes passing JSON difficult.
// As a workaround, by telling Windows Command Prompt (cmd.exe) to execute a command to completion (/c) and leave spaces intact (/s), combined with feeding arguments as an argument array into child_process, we can get around this mess.
// As a workaround, we:
// 1. Wrap the CLI command with a Windows Command Prompt (cmd.exe) process, and
// 2. Execute the command to completion (via the /c option), and
// 3. Leave spaces intact (via the /s option), and
// 4. Feed the arguments as an argument array into `child_process.spawn`.
// End-result is a process that looks like:
// cmd.exe "/s" "/c" "slack" "app" "list"
const windowsArgs = ['/s', '/c'].concat([command]).concat(args);
return [
'cmd',
Expand Down

0 comments on commit bcbc1fd

Please sign in to comment.