diff --git a/src/cli/commands/run.js b/src/cli/commands/run.js index e18d033c15..d1ea07d4a9 100644 --- a/src/cli/commands/run.js +++ b/src/cli/commands/run.js @@ -79,7 +79,8 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg for (const [stage, cmd] of cmds) { // only tack on trailing arguments for default script, ignore for pre and post - #1595 const cmdWithArgs = stage === action ? sh`${unquoted(cmd)} ${args}` : cmd; - await execCommand(stage, config, cmdWithArgs, config.cwd); + const customShell = config.getOption('script-shell'); + await execCommand(stage, config, cmdWithArgs, config.cwd, customShell ? String(customShell) : undefined); } } else if (action === 'env') { reporter.log(JSON.stringify(await makeEnv('env', config.cwd, config), null, 2), {force: true}); diff --git a/src/util/execute-lifecycle-script.js b/src/util/execute-lifecycle-script.js index 07fd5bb643..5ed15fd2d4 100644 --- a/src/util/execute-lifecycle-script.js +++ b/src/util/execute-lifecycle-script.js @@ -171,6 +171,7 @@ export async function executeLifecycleScript( cwd: string, cmd: string, spinner?: ReporterSpinner, + customShell?: string, ): LifecycleReturn { // if we don't have a spinner then pipe everything to the terminal const stdio = spinner ? undefined : 'inherit'; @@ -183,7 +184,6 @@ export async function executeLifecycleScript( let sh = 'sh'; let shFlag = '-c'; - const customShell = config.getOption('script-shell'); let windowsVerbatimArguments = undefined; if (customShell) { @@ -271,11 +271,17 @@ export async function execFromManifest(config: Config, commandName: string, cwd: } } -export async function execCommand(stage: string, config: Config, cmd: string, cwd: string): Promise { +export async function execCommand( + stage: string, + config: Config, + cmd: string, + cwd: string, + customShell?: string, +): Promise { const {reporter} = config; try { reporter.command(cmd); - await executeLifecycleScript(stage, config, cwd, cmd); + await executeLifecycleScript(stage, config, cwd, cmd, undefined, customShell); return Promise.resolve(); } catch (err) { if (err instanceof ProcessTermError) {