Skip to content

Commit

Permalink
fix(cli): avoid cmd.exe windows popping up during execution
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Aug 11, 2021
1 parent 18b9522 commit ddb5ab9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/src/plugins/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export async function buildExecModule({ module, log }: BuildModuleParams<ExecMod
const result = await exec(command.join(" "), [], {
cwd: module.buildPath,
env: getDefaultEnvVars(module),
// TODO: remove this in 0.13 and alert users to use e.g. sh -c '<script>' instead.
shell: true,
})

Expand Down
2 changes: 1 addition & 1 deletion core/src/util/ext-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class CliWrapper {
}

log.debug(`Spawning '${path} ${args.join(" ")}' in ${cwd}`)
return crossSpawn(path, args, { cwd, env })
return crossSpawn(path, args, { cwd, env, windowsHide: true })
}

async spawnAndWait({ args, cwd, env, log, ignoreError, rawMode, stdout, stderr, timeoutSec, tty }: SpawnParams) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ interface ExecOpts extends execa.Options {
*/
export async function exec(cmd: string, args: string[], opts: ExecOpts = {}) {
// Ensure buffer is always set to true so that we can read the error output
opts = { ...opts, buffer: true, all: true }
opts = { windowsHide: true, ...opts, buffer: true, all: true }
const proc = execa(cmd, args, omit(opts, ["stdout", "stderr"]))

opts.stdout && proc.stdout && proc.stdout.pipe(opts.stdout)
Expand Down Expand Up @@ -242,7 +242,7 @@ export function spawn(cmd: string, args: string[], opts: SpawnOpts = {}) {
} = opts

const stdio = tty ? "inherit" : "pipe"
const proc = _spawn(cmd, args, { cwd, env, stdio })
const proc = _spawn(cmd, args, { cwd, env, stdio, windowsHide: true })

const result: SpawnOutput = {
code: 0,
Expand Down

0 comments on commit ddb5ab9

Please sign in to comment.