Skip to content

Commit

Permalink
[eas-cli] Enhance eas env:exec command by enabling shell execution …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
tharakadesilva committed Dec 22, 2024
1 parent a1d086f commit 7ebf630
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/eas-cli/src/commands/env/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand All @@ -111,7 +120,8 @@ export default class EnvExec extends EasCommand {
environmentVariables: Record<string, string>;
}): Promise<void> {
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,
Expand Down

0 comments on commit 7ebf630

Please sign in to comment.