@@ -103,19 +103,23 @@ export const defaults: Options = {
103
103
kill,
104
104
}
105
105
const isWin = process . platform == 'win32'
106
- try {
107
- defaults . shell = which . sync ( 'bash' )
108
- defaults . prefix = 'set -euo pipefail;'
109
- defaults . quote = quote
110
- } catch ( err ) {
111
- if ( isWin ) {
112
- try {
113
- defaults . shell = which . sync ( 'powershell.exe' )
114
- defaults . postfix = '; exit $LastExitCode'
115
- defaults . quote = quotePowerShell
116
- } catch ( err ) {
117
- // no powershell?
118
- }
106
+
107
+ export function setupPowerShell ( ) {
108
+ $ . shell = which . sync ( 'powershell.exe' )
109
+ $ . prefix = ''
110
+ $ . postfix = '; exit $LastExitCode'
111
+ $ . quote = quotePowerShell
112
+ }
113
+
114
+ export function setupBash ( ) {
115
+ $ . shell = which . sync ( 'bash' )
116
+ $ . prefix = 'set -euo pipefail;'
117
+ $ . quote = quote
118
+ }
119
+
120
+ function checkShell ( ) {
121
+ if ( ! $ . shell ) {
122
+ throw new Error ( `shell is not available: setup guide goes here` )
119
123
}
120
124
}
121
125
@@ -125,6 +129,8 @@ function getStore() {
125
129
126
130
export const $ : Shell & Options = new Proxy < Shell & Options > (
127
131
function ( pieces , ...args ) {
132
+ checkShell ( )
133
+
128
134
if ( ! Array . isArray ( pieces ) ) {
129
135
return function ( this : any , ...args : any ) {
130
136
const self = this
@@ -179,6 +185,10 @@ export const $: Shell & Options = new Proxy<Shell & Options>(
179
185
}
180
186
)
181
187
188
+ try {
189
+ setupBash ( )
190
+ } catch ( err ) { }
191
+
182
192
type Resolve = ( out : ProcessOutput ) => void
183
193
type IO = StdioPipe | StdioNull
184
194
0 commit comments