Commit 5055384

Anton Medvedev <anton@medv.io>
2022-06-21 01:08:21
Simplify context initialization
1 parent a1a5ca7
Changed files (1)
src/core.ts
@@ -59,32 +59,26 @@ const hook = createHook({
 })
 hook.enable()
 
-const initStore = (() => {
-  const context: Options = {
-    [processCwd]: process.cwd(),
-    verbose: (global as any).ZX_VERBOSE ?? true,
-    env: process.env,
-    shell: true,
-    prefix: '',
-    quote,
-    spawn,
-    log,
-  }
-
-  try {
-    context.shell = which.sync('bash')
-    context.prefix = 'set -euo pipefail;'
-  } catch (err) {
-    // ¯\_(ツ)_/¯
-  }
+const context: Options = {
+  [processCwd]: process.cwd(),
+  verbose: (global as any).ZX_VERBOSE ?? true,
+  env: process.env,
+  shell: true,
+  prefix: '',
+  quote,
+  spawn,
+  log,
+}
 
-  return function initStore(): Options {
-    return context
-  }
-})()
+try {
+  context.shell = which.sync('bash')
+  context.prefix = 'set -euo pipefail;'
+} catch (err) {
+  // ¯\_(ツ)_/¯
+}
 
 function getStore() {
-  return storage.getStore() || initStore()
+  return storage.getStore() || context
 }
 
 export const $ = new Proxy<Shell & Options>(