-
-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #864 from okonet/updates
Updates
- Loading branch information
Showing
7 changed files
with
971 additions
and
770 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
'use strict' | ||
|
||
const getRenderer = ({ debug, quiet }, env = process.env) => { | ||
if (quiet) return 'silent' | ||
if (quiet) return { renderer: 'silent' } | ||
// Better support for dumb terminals: https://en.wikipedia.org/wiki/Computer_terminal#Dumb_terminals | ||
const isDumbTerminal = env.TERM === 'dumb' | ||
if (isDumbTerminal || env.NODE_ENV === 'test') return 'test' | ||
if (debug) return 'verbose' | ||
return 'update' | ||
if (debug || isDumbTerminal || env.NODE_ENV === 'test') return { renderer: 'verbose' } | ||
return { renderer: 'update', rendererOptions: { dateFormat: false } } | ||
} | ||
|
||
module.exports = getRenderer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,28 @@ | ||
import getRenderer from '../lib/getRenderer' | ||
|
||
describe('getRenderer', () => { | ||
it('should return silent when quiet', () => { | ||
expect(getRenderer({ quiet: true }, {})).toEqual('silent') | ||
it('should return silent renderer when quiet', () => { | ||
expect(getRenderer({ quiet: true }, {})).toEqual({ renderer: 'silent' }) | ||
}) | ||
|
||
it('should return test when NODE_ENV=test', () => { | ||
expect(getRenderer({}, { NODE_ENV: 'test' })).toEqual('test') | ||
it('should return verbose renderer when NODE_ENV=test', () => { | ||
expect(getRenderer({}, { NODE_ENV: 'test' })).toEqual({ renderer: 'verbose' }) | ||
}) | ||
|
||
it('should return test when TERM=dumb', () => { | ||
expect(getRenderer({}, { TERM: 'dumb' })).toEqual('test') | ||
it('should return test renderer when TERM=dumb', () => { | ||
expect(getRenderer({}, { TERM: 'dumb' })).toEqual({ renderer: 'verbose' }) | ||
}) | ||
|
||
it('should return verbose when debug', () => { | ||
expect(getRenderer({ debug: true }, {})).toEqual('verbose') | ||
it('should return verbose renderer when debug', () => { | ||
expect(getRenderer({ debug: true }, {})).toEqual({ renderer: 'verbose' }) | ||
}) | ||
|
||
it('should return update by default', () => { | ||
expect(getRenderer({}, {})).toEqual('update') | ||
it('should return update renderer by default', () => { | ||
expect(getRenderer({}, {})).toEqual({ | ||
renderer: 'update', | ||
rendererOptions: { | ||
dateFormat: false, | ||
}, | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.