Commit 1224dd4

Anton Medvedev <anton@medv.io>
2022-06-21 01:17:01
Make sure REPL starts with verbosity off
1 parent 1593598
Changed files (3)
src/core.ts
@@ -59,9 +59,9 @@ const hook = createHook({
 })
 hook.enable()
 
-const defaults: Options = {
+export const defaults: Options = {
   [processCwd]: process.cwd(),
-  verbose: (global as any).ZX_VERBOSE ?? true,
+  verbose: true,
   env: process.env,
   shell: true,
   prefix: '',
src/repl.ts
@@ -17,10 +17,10 @@ import os from 'node:os'
 import path from 'node:path'
 import repl from 'node:repl'
 import { inspect } from 'node:util'
-import { ProcessOutput } from './core.js'
+import { ProcessOutput, defaults } from './core.js'
 
 export function startRepl() {
-  ;(global as any).ZX_VERBOSE = false
+  defaults.verbose = false
   const r = repl.start({
     prompt: chalk.greenBright.bold('❯ '),
     useGlobal: true,
test/cli.test.js
@@ -62,6 +62,14 @@ test('starts repl with -i', async () => {
   assert.match(out.stdout, 'bar')
 })
 
+test('starts repl with verbosity off', async () => {
+  let p = $`node build/cli.js -i`
+  p.stdin.write('"verbose" + " is " + $.verbose\n')
+  p.stdin.end()
+  let out = await p
+  assert.match(out.stdout, 'verbose is false')
+})
+
 test('supports `--experimental` flag', async () => {
   let out = await $`echo 'echo("test")' | node build/cli.js --experimental`
   assert.match(out.stdout, 'test')