Skip to content

Commit

Permalink
fix: use stdout as log default stream (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 1, 2022
1 parent 2c8711c commit bef2625
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/print.ts
Expand Up @@ -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' },
Expand Down
12 changes: 6 additions & 6 deletions test/log.test.js
Expand Up @@ -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
Expand Down

0 comments on commit bef2625

Please sign in to comment.