Skip to content

Commit

Permalink
feat: add usePwsh for PowerShell v7+
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Apr 29, 2024
1 parent eda722c commit 085e00a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ export function usePowerShell() {
$.quote = quotePowerShell
}

export function usePwsh() {
$.shell = which.sync('pwsh')
$.prefix = ''
$.postfix = '; exit $LastExitCode'
$.quote = quotePowerShell
}

export function useBash() {
$.shell = which.sync('bash')
$.prefix = 'set -euo pipefail;'
Expand Down
1 change: 1 addition & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ declare global {
var quotePowerShell: typeof _.quotePowerShell
var retry: typeof _.retry
var usePowerShell: typeof _.usePowerShell
var usePwsh: typeof _.usePwsh
var useBash: typeof _.useBash
var sleep: typeof _.sleep
var spinner: typeof _.spinner
Expand Down
2 changes: 2 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
cd,
syncProcessCwd,
usePowerShell,
usePwsh,
useBash,
kill,
ProcessOutput,
Expand Down Expand Up @@ -69,6 +70,7 @@ describe('index', () => {
assert(defaults)
assert(within)
assert(usePowerShell)
assert(usePwsh)
assert(useBash)

// goods
Expand Down

0 comments on commit 085e00a

Please sign in to comment.