Skip to content

Commit 4533cfd

Browse files
committed
add no-color option
1 parent 1bbc431 commit 4533cfd

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

packages/gatsby-cli/src/create-cli.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ function buildLocalCommands(cli, isLocalSite) {
6060
function getCommandHandler(command, handler) {
6161
return argv => {
6262
report.setVerbose(!!argv.verbose)
63-
63+
report.setNoColor(!!argv.noColor)
64+
6465
process.env.gatsby_log_level = argv.verbose ? `verbose` : `normal`
6566
report.verbose(`set gatsby_log_level: "${process.env.gatsby_log_level}"`)
6667

@@ -175,6 +176,12 @@ module.exports = (argv, handlers) => {
175176
describe: `Turn on verbose output`,
176177
global: true,
177178
})
179+
.option(`no-color`,{
180+
default: false,
181+
type: `boolean`,
182+
describe: `Turn off the color in output`,
183+
global: true,
184+
})
178185

179186
buildLocalCommands(cli, isLocalSite)
180187

packages/gatsby-cli/src/reporter/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ module.exports = Object.assign(reporter, {
1717
setVerbose(isVerbose = true) {
1818
this.isVerbose = !!isVerbose
1919
},
20-
20+
setNoColor(isNoColor = false){
21+
if(isNoColor){
22+
errorFormatter.withoutColors()
23+
}
24+
},
2125
panic(...args) {
2226
this.error(...args)
2327
process.exit(1)

0 commit comments

Comments
 (0)