From f4a65e374681512ee934b1135fc61ceed652171a 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/eas-cli/src/commands/env/exec.ts b/packages/eas-cli/src/commands/env/exec.ts index 1a30824df2..86c36b84c9 100644 --- a/packages/eas-cli/src/commands/env/exec.ts +++ b/packages/eas-cli/src/commands/env/exec.ts @@ -107,10 +107,17 @@ export default class EnvExec extends EasCommand { throw new Error("Invalid environment. Use one of 'production', 'preview', or 'development'."); } + const firstChar = bash_command[0]; + const lastChar = bash_command[bash_command.length - 1]; + const cleanCommand = + (firstChar === '"' && lastChar === '"') || (firstChar === "'" && lastChar === "'") + ? bash_command.slice(1, -1) + : bash_command; + return { nonInteractive: rawFlags['non-interactive'], environment, - command: bash_command, + command: cleanCommand, }; } @@ -149,7 +156,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,