Skip to content

Commit ca3bb18

Browse files
committed
Always try bash first
1 parent 4883e84 commit ca3bb18

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

src/globals.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ declare global {
3535
var path: typeof _.path
3636
var question: typeof _.question
3737
var quiet: typeof _.quiet
38+
var quote: typeof _.quote
39+
var quotePowerShell: typeof _.quotePowerShell
3840
var sleep: typeof _.sleep
3941
var stdin: typeof _.stdin
4042
var which: typeof _.which

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export {
4343
YAML,
4444
} from './goods.js'
4545

46-
export { Duration } from './util.js'
46+
export { Duration, quote, quotePowerShell } from './util.js'
4747

4848
/**
4949
* @deprecated Use $.nothrow() instead.

test-d/globals.test-d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ expectType<ProcessPromise>(p)
2323
let o = await p
2424
assert(o instanceof ProcessOutput)
2525
expectType<ProcessOutput>(o)
26+
27+
expectType<string>(quote('foo'))
28+
expectType<string>(quotePowerShell('foo'))

test/win32.test.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,23 @@ $.verbose = false
2222

2323
if (process.platform === 'win32') {
2424
test('should work with windows-specific commands', async () => {
25-
const p = await $`get-host`
26-
assert.match(p.stdout, /PowerShell/)
25+
const p = await $`echo $0` // Bash is first by default.
26+
assert.match(p.stdout, /bash/)
27+
await within(async () => {
28+
$.shell = which.sync('powershell.exe')
29+
$.quote = quotePowerShell
30+
const p = await $`get-host`
31+
assert.match(p.stdout, /PowerShell/)
32+
})
2733
})
2834

2935
test('quotePowerShell works', async () => {
30-
const p = await $`echo ${`Windows 'rulez!'`}`
31-
assert.match(p.stdout, /Windows 'rulez!'/)
36+
await within(async () => {
37+
$.shell = which.sync('powershell.exe')
38+
$.quote = quotePowerShell
39+
const p = await $`echo ${`Windows 'rulez!'`}`
40+
assert.match(p.stdout, /Windows 'rulez!'/)
41+
})
3242
})
3343
}
3444

0 commit comments

Comments
 (0)