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 authored and wschurman committed Jan 10, 2025
1 parent 37a32c9 commit f4a65e3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/eas-cli/src/commands/env/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down Expand Up @@ -149,7 +156,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 f4a65e3

Please sign in to comment.