Commit bef2625

Anton Golub <antongolub@antongolub.com>
2022-06-01 17:56:55
fix: use stdout as log default stream (#419)
v6
1 parent 2c8711c
Changed files (2)
src/print.ts
@@ -53,11 +53,11 @@ export function log(
   if (!ig.ignores(scope)) {
     msg = raw ? msg[0] : asArray(logFormat(msg)).join(' ') + '\n'
     // @ts-ignore
-    logPrint(...(logOutput === 'stdout' ? [msg] : [null, msg]))
+    logPrint(...(logOutput === 'stderr' ? [null, msg] : [msg]))
   }
 }
 
-export function printCmd(cmd: string) {
+export function printCmd(cmd: string): void {
   if (/\n/.test(cmd)) {
     log(
       { scope: 'cmd' },
test/log.test.js
@@ -31,14 +31,14 @@ test('logger works', async () => {
   log({ scope: 'baz' }, 'baz-test')
   log({ scope: 'fetch' }, 'example.com')
 
-  assert.ok(stderr.includes('FOO-TEST'))
-  assert.ok(!stderr.includes('BAR-TEST'))
-  assert.ok(!stderr.includes('BAZ-TEST'))
-  assert.ok(!stderr.includes('EXAMPLE.COM'))
+  assert.ok(stdout.includes('FOO-TEST'))
+  assert.ok(!stdout.includes('BAR-TEST'))
+  assert.ok(!stdout.includes('BAZ-TEST'))
+  assert.ok(!stdout.includes('EXAMPLE.COM'))
 
-  $.logOutput = 'stdout'
+  $.logOutput = 'stderr'
   log({ scope: 'foo' }, 'foo')
-  assert.ok(stdout.includes('FOO'))
+  assert.ok(stderr.includes('FOO'))
 
   delete $.logPrint
   delete $.logFormat