From 7ebf630e2d021cecfe5be4fe4621258e114a8c70 Mon Sep 17 00:00:00 2001 From: Tharaka De Silva Date: Sun, 22 Dec 2024 00:10:13 +0100 Subject: [PATCH] [eas-cli] Enhance `eas env:exec` command by enabling shell execution for commands * This change allows for better command handling and execution within the environment context. * Fix command execution in env:exec to handle various command formats properly. --- packages/eas-cli/src/commands/env/exec.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/eas-cli/src/commands/env/exec.ts b/packages/eas-cli/src/commands/env/exec.ts index 227e340c13..6798b7ca2f 100644 --- a/packages/eas-cli/src/commands/env/exec.ts +++ b/packages/eas-cli/src/commands/env/exec.ts @@ -96,10 +96,19 @@ export default class EnvExec extends EasCommand { throw new Error("Invalid environment. Use one of 'production', 'preview', or 'development'."); } + let cleanCommand = bash_command; + if (bash_command) { + const firstChar = bash_command[0]; + const lastChar = bash_command[bash_command.length - 1]; + if ((firstChar === '"' && lastChar === '"') || (firstChar === "'" && lastChar === "'")) { + cleanCommand = bash_command.slice(1, -1); + } + } + return { nonInteractive: rawFlags['non-interactive'], environment, - command: bash_command, + command: cleanCommand, }; } @@ -111,7 +120,8 @@ export default class EnvExec extends EasCommand { environmentVariables: Record; }): Promise { Log.log(`Running command: ${chalk.bold(command)}`); - const spawnPromise = spawnAsync('bash', ['-c', command], { + const spawnPromise = spawnAsync(command, [], { + shell: true, stdio: ['inherit', 'pipe', 'pipe'], env: { ...process.env,