diff --git a/extensions/kind/src/util.ts b/extensions/kind/src/util.ts index ae0316f4ba3cc..f06e141ea68ae 100644 --- a/extensions/kind/src/util.ts +++ b/extensions/kind/src/util.ts @@ -69,6 +69,8 @@ export function runCliCommand(command: string, args: string[], options?: RunOpti // In production mode, applications don't have access to the 'user' path like brew if (isMac || isWindows) { env.PATH = getKindPath(); + // Escape any whitespaces in command + command = `"${command}"`; } else if (env.FLATPAK_ID) { // need to execute the command on the host args = ['--host', command, ...args]; @@ -79,9 +81,6 @@ export function runCliCommand(command: string, args: string[], options?: RunOpti env = Object.assign(env, options.env); } - // Escape any whitespaces in command - command = command.replace(/(\s+)/g, '\\$1'); - const spawnProcess = spawn(command, args, { shell: isWindows, env }); // do not reject as we want to store exit code in the result spawnProcess.on('error', error => { diff --git a/extensions/podman/src/util.ts b/extensions/podman/src/util.ts index a1944c58b2719..c5c175993501f 100644 --- a/extensions/podman/src/util.ts +++ b/extensions/podman/src/util.ts @@ -63,6 +63,8 @@ export function runCliCommand(command: string, args: string[], options?: RunOpti // In production mode, applications don't have access to the 'user' path like brew if (isMac || isWindows) { env.PATH = getInstallationPath(); + // Escape any whitespaces in command + command = `"${command}"`; } else if (env.FLATPAK_ID) { // need to execute the command on the host args = ['--host', command, ...args]; @@ -73,9 +75,6 @@ export function runCliCommand(command: string, args: string[], options?: RunOpti env = Object.assign(env, options.env); } - // Escape any whitespaces in command - command = command.replace(/(\s+)/g, '\\$1'); - const spawnProcess = spawn(command, args, { shell: isWindows, env }); spawnProcess.on('error', err => { reject(err);