feat: add sync execPowershell

This commit is contained in:
Amin Yahyaabadi 2022-08-07 17:36:27 -07:00
parent 897c5f67c8
commit 92711bc219
3 changed files with 22 additions and 2 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -24,6 +24,26 @@ export function execPowershell(
return execa(getPowerShell(), [...startupFlags, "-c", command], execOptions)
}
/**
* Execute a powershell command.
*
* @param command The powershell command to execute
* @param startupFlags The optional startup flags to be passed to powershell.
*
* Defaults to `["-NoProfile", "-NoLogo", "-NonInteractive"]`. This means that the Powershell profile is not sourced first.
* @param execOptions The options passed to `execa`.
*
* Defaults to `{ stdio: "inherit" }`
* @note It prefers `pwsh` over `powershell`
*/
export function execPowershellSync(
command: string,
startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"],
execOptions: execa.SyncOptions = { stdio: "inherit" }
) {
return execa.sync(getPowerShell(), [...startupFlags, "-c", command], execOptions)
}
/**
* Get the path to the powershell executable.
*