Skip to content
This repository was archived by the owner on Aug 10, 2020. It is now read-only.

Commit 1af482a

Browse files
committed
suppress logs if —silent flag passed into command
1 parent d308c4d commit 1af482a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { Command } = require('@oclif/command')
22
const chalk = require('chalk')
33
const API = require('netlify')
4+
const { format, inspect } = require('util')
45
const getConfigPath = require('./utils/get-config-path')
56
const readConfig = require('./utils/read-config')
67
const globalConfig = require('./global-config')
@@ -65,6 +66,14 @@ class BaseCommand extends Command {
6566
}
6667
}
6768

69+
log(message = '', ...args) {
70+
if (this.argv && this.argv.includes('--silent')) {
71+
return
72+
}
73+
message = typeof message === 'string' ? message : inspect(message)
74+
process.stdout.write(format(message, ...args) + '\n')
75+
}
76+
6877
parse(opts, argv = this.argv) {
6978
/* enrich parse with global flags */
7079
const globalFlags = {}
@@ -197,4 +206,4 @@ class BaseCommand extends Command {
197206
}
198207
}
199208

200-
module.exports = BaseCommand
209+
module.exports = BaseCommand

0 commit comments

Comments
 (0)