@@ -40,7 +40,6 @@ import {
40
40
parseDuration ,
41
41
quote ,
42
42
quotePowerShell ,
43
- noquote ,
44
43
preferNmBin ,
45
44
} from './util.js'
46
45
@@ -74,7 +73,7 @@ export interface Options {
74
73
nothrow : boolean
75
74
prefix : string
76
75
postfix : string
77
- quote : typeof quote
76
+ quote ? : typeof quote
78
77
quiet : boolean
79
78
detached : boolean
80
79
preferLocal : boolean
@@ -114,7 +113,6 @@ export const defaults: Options = {
114
113
quiet : false ,
115
114
prefix : '' ,
116
115
postfix : '' ,
117
- quote : noquote ,
118
116
detached : false ,
119
117
preferLocal : false ,
120
118
spawn,
@@ -145,9 +143,15 @@ export function useBash() {
145
143
}
146
144
147
145
function checkShell ( ) {
148
- if ( ! $ . shell ) {
149
- throw new Error ( `shell is not available: setup guide goes here` )
150
- }
146
+ if ( ! $ . shell )
147
+ throw new Error (
148
+ `No shell is available: https://google.github.io/zx/setup#bash`
149
+ )
150
+ }
151
+
152
+ function checkQuote ( ) {
153
+ if ( ! $ . quote )
154
+ throw new Error ( 'No quote function is defined: https://ï.at/no-quote-func' )
151
155
}
152
156
153
157
function getStore ( ) {
@@ -156,8 +160,6 @@ function getStore() {
156
160
157
161
export const $ : Shell & Options = new Proxy < Shell & Options > (
158
162
function ( pieces , ...args ) {
159
- checkShell ( )
160
-
161
163
if ( ! Array . isArray ( pieces ) ) {
162
164
return function ( this : any , ...args : any ) {
163
165
const self = this
@@ -170,10 +172,13 @@ export const $: Shell & Options = new Proxy<Shell & Options>(
170
172
if ( pieces . some ( ( p ) => p == undefined ) ) {
171
173
throw new Error ( `Malformed command at ${ from } ` )
172
174
}
175
+ checkShell ( )
176
+ checkQuote ( )
177
+
173
178
let resolve : Resolve , reject : Resolve
174
179
const promise = new ProcessPromise ( ( ...args ) => ( [ resolve , reject ] = args ) )
175
180
const cmd = buildCmd (
176
- $ . quote ,
181
+ $ . quote as typeof quote ,
177
182
pieces as TemplateStringsArray ,
178
183
args
179
184
) as string
0 commit comments