Skip to content

Commit

Permalink
fix: update listr2@2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed May 15, 2020
1 parent fc72170 commit 157ad3e
Show file tree
Hide file tree
Showing 7 changed files with 867 additions and 714 deletions.
7 changes: 3 additions & 4 deletions lib/getRenderer.js
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
4 changes: 2 additions & 2 deletions lib/runAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ const runAll = async (

const listrOptions = {
ctx,
dateFormat: false,
exitOnError: false,
renderer: getRenderer({ debug, quiet }),
nonTTYRenderer: 'verbose',
...getRenderer({ debug, quiet }),
}

const listrTasks = []
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,37 @@
},
"dependencies": {
"chalk": "^4.0.0",
"commander": "^5.0.0",
"commander": "^5.1.0",
"cosmiconfig": "^6.0.0",
"debug": "^4.1.1",
"dedent": "^0.7.0",
"execa": "^4.0.0",
"listr2": "1.3.8",
"log-symbols": "^3.0.0",
"listr2": "2.0.1",
"log-symbols": "^4.0.0",
"micromatch": "^4.0.2",
"normalize-path": "^3.0.0",
"please-upgrade-node": "^3.2.0",
"string-argv": "0.3.1",
"stringify-object": "^3.3.0"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
"@babel/preset-env": "^7.9.5",
"@babel/core": "^7.9.6",
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"babel-eslint": "10.1.0",
"babel-jest": "^25.3.0",
"babel-jest": "^26.0.1",
"consolemock": "^1.1.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.3",
"fs-extra": "^9.0.0",
"husky": "^4.2.5",
"jest": "^25.3.0",
"jest": "^26.0.1",
"jest-snapshot-serializer-ansi": "^1.0.0",
"nanoid": "^3.1.3",
"prettier": "^2.0.4"
"nanoid": "^3.1.5",
"prettier": "^2.0.5"
},
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion test/__mocks__/cosmiconfig.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const actual = require.requireActual('cosmiconfig')
const actual = jest.requireActual('cosmiconfig')

function cosmiconfig(name, options) {
return actual.cosmiconfig(name, options)
Expand Down
25 changes: 15 additions & 10 deletions test/getRenderer.spec.js
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,
},
})
})
})
6 changes: 3 additions & 3 deletions test/index2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('lintStaged', () => {
"quiet": true,
"shouldBackup": true,
},
"dateFormat": false,
"exitOnError": false,
"nonTTYRenderer": "verbose",
"renderer": "silent",
}
`)
Expand All @@ -56,9 +56,9 @@ describe('lintStaged', () => {
"quiet": false,
"shouldBackup": true,
},
"dateFormat": false,
"exitOnError": false,
"renderer": "test",
"nonTTYRenderer": "verbose",
"renderer": "verbose",
}
`)
})
Expand Down
Loading

0 comments on commit 157ad3e

Please sign in to comment.