|
1 | 1 | const { Command } = require('@oclif/command')
|
2 |
| -const chalk = require('chalk') |
3 | 2 | const API = require('netlify')
|
| 3 | +const merge = require('lodash.merge') |
4 | 4 | const { format, inspect } = require('util')
|
5 | 5 | const getConfigPath = require('./utils/get-config-path')
|
6 | 6 | const readConfig = require('./utils/read-config')
|
7 | 7 | const globalConfig = require('./global-config')
|
8 | 8 | const StateConfig = require('./state')
|
| 9 | +const chalkInstance = require('./utils/chalk') |
9 | 10 | const openBrowser = require('./utils/open-browser')
|
10 | 11 | const findRoot = require('./utils/find-root')
|
11 | 12 | const { track, identify } = require('./utils/telemetry')
|
12 |
| -const merge = require('lodash.merge') |
| 13 | + |
13 | 14 | const argv = require('minimist')(process.argv.slice(2))
|
14 | 15 | const { NETLIFY_AUTH_TOKEN } = process.env
|
15 | 16 |
|
@@ -127,6 +128,10 @@ class BaseCommand extends Command {
|
127 | 128 | }, opts))
|
128 | 129 | }
|
129 | 130 |
|
| 131 | + get chalk() { |
| 132 | + // If --json flag disable chalk colors |
| 133 | + return chalkInstance(argv.json) |
| 134 | + } |
130 | 135 | /**
|
131 | 136 | * Get user netlify API token
|
132 | 137 | * @param {string} - [tokenFromFlag] - value passed in by CLI flag
|
@@ -212,11 +217,11 @@ class BaseCommand extends Command {
|
212 | 217 |
|
213 | 218 | // Log success
|
214 | 219 | this.log()
|
215 |
| - this.log(`${chalk.greenBright('You are now logged into your Netlify account!')}`) |
| 220 | + this.log(`${this.chalk.greenBright('You are now logged into your Netlify account!')}`) |
216 | 221 | this.log()
|
217 |
| - this.log(`Run ${chalk.cyanBright('netlify status')} for account details`) |
| 222 | + this.log(`Run ${this.chalk.cyanBright('netlify status')} for account details`) |
218 | 223 | this.log()
|
219 |
| - this.log(`To see all available commands run: ${chalk.cyanBright('netlify help')}`) |
| 224 | + this.log(`To see all available commands run: ${this.chalk.cyanBright('netlify help')}`) |
220 | 225 | this.log()
|
221 | 226 | return accessToken
|
222 | 227 | }
|
|
0 commit comments