Skip to content

Commit

Permalink
Add a no-color option to disable the colors (#3755)
Browse files Browse the repository at this point in the history
* disable boolean-negation in yargs

* add no-color option
  • Loading branch information
cricrio authored and KyleAMathews committed Jan 29, 2018
1 parent 36742df commit 1f516aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@
"build": "babel src --out-dir lib --ignore __tests__",
"watch": "babel -w src --out-dir lib --ignore __tests__",
"prepublish": "cross-env NODE_ENV=production npm run build"
},
"yargs": {
"boolean-negation": false
}
}
9 changes: 8 additions & 1 deletion packages/gatsby-cli/src/create-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function buildLocalCommands(cli, isLocalSite) {
function getCommandHandler(command, handler) {
return argv => {
report.setVerbose(!!argv.verbose)

report.setNoColor(!!argv.noColor)

process.env.gatsby_log_level = argv.verbose ? `verbose` : `normal`
report.verbose(`set gatsby_log_level: "${process.env.gatsby_log_level}"`)

Expand Down Expand Up @@ -175,6 +176,12 @@ module.exports = (argv, handlers) => {
describe: `Turn on verbose output`,
global: true,
})
.option(`no-color`,{
default: false,
type: `boolean`,
describe: `Turn off the color in output`,
global: true,
})

buildLocalCommands(cli, isLocalSite)

Expand Down
6 changes: 5 additions & 1 deletion packages/gatsby-cli/src/reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ module.exports = Object.assign(reporter, {
setVerbose(isVerbose = true) {
this.isVerbose = !!isVerbose
},

setNoColor(isNoColor = false){
if(isNoColor){
errorFormatter.withoutColors()
}
},
panic(...args) {
this.error(...args)
process.exit(1)
Expand Down

0 comments on commit 1f516aa

Please sign in to comment.