Skip to content

Commit

Permalink
Always try bash first
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Oct 7, 2022
1 parent 4883e84 commit ca3bb18
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ declare global {
var path: typeof _.path
var question: typeof _.question
var quiet: typeof _.quiet
var quote: typeof _.quote
var quotePowerShell: typeof _.quotePowerShell
var sleep: typeof _.sleep
var stdin: typeof _.stdin
var which: typeof _.which
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export {
YAML,
} from './goods.js'

export { Duration } from './util.js'
export { Duration, quote, quotePowerShell } from './util.js'

/**
* @deprecated Use $.nothrow() instead.
Expand Down
3 changes: 3 additions & 0 deletions test-d/globals.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ expectType<ProcessPromise>(p)
let o = await p
assert(o instanceof ProcessOutput)
expectType<ProcessOutput>(o)

expectType<string>(quote('foo'))
expectType<string>(quotePowerShell('foo'))
18 changes: 14 additions & 4 deletions test/win32.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ $.verbose = false

if (process.platform === 'win32') {
test('should work with windows-specific commands', async () => {
const p = await $`get-host`
assert.match(p.stdout, /PowerShell/)
const p = await $`echo $0` // Bash is first by default.
assert.match(p.stdout, /bash/)
await within(async () => {
$.shell = which.sync('powershell.exe')
$.quote = quotePowerShell
const p = await $`get-host`
assert.match(p.stdout, /PowerShell/)
})
})

test('quotePowerShell works', async () => {
const p = await $`echo ${`Windows 'rulez!'`}`
assert.match(p.stdout, /Windows 'rulez!'/)
await within(async () => {
$.shell = which.sync('powershell.exe')
$.quote = quotePowerShell
const p = await $`echo ${`Windows 'rulez!'`}`
assert.match(p.stdout, /Windows 'rulez!'/)
})
})
}

Expand Down

0 comments on commit ca3bb18

Please sign in to comment.