Skip to content

Commit

Permalink
fix(cli): Correct value for FORCE_COLOR env var (#451)
Browse files Browse the repository at this point in the history
The "support-color" package expects to parse an integer value. Code was wrongly assigning a boolean
when envvars are strings. Don't see how this ever worked. Additionally removed resetting of
`process.exitCode` to its default value, and migrated `process.exitCode` to top of catch blocks.

Fixes #448
  • Loading branch information
plroebuck authored and okonet committed May 18, 2018
1 parent 1601c02 commit 9823d26
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const debug = require('debug')('lint-staged')
// but do this only in TTY mode
if (process.stdout.isTTY) {
// istanbul ignore next
process.env.FORCE_COLOR = true
process.env.FORCE_COLOR = '1'
}

const errConfigNotFound = new Error('Config could not be found')
Expand Down Expand Up @@ -53,15 +53,15 @@ module.exports = function lintStaged(logger = console, configPath, debugMode) {
.then(() => {
debug('linters were executed successfully!')
// No errors, exiting with 0
process.exitCode = 0
})
.catch(error => {
// Errors detected, printing and exiting with non-zero
printErrors(error)
process.exitCode = 1
printErrors(error)
})
})
.catch(err => {
process.exitCode = 1
if (err === errConfigNotFound) {
logger.error(`${err.message}.`)
} else {
Expand All @@ -78,6 +78,5 @@ module.exports = function lintStaged(logger = console, configPath, debugMode) {
Please make sure you have created it correctly.
See https://github.com/okonet/lint-staged#configuration.
`)
process.exitCode = 1
})
}

0 comments on commit 9823d26

Please sign in to comment.