mirror of
https://github.com/typicode/json-server.git
synced 2025-08-02 02:53:21 +08:00
feature: add optional --quiet
argument
Suppress log messages from output. - Use logger middleware only if `--quiet` is `false`
This commit is contained in:
@ -44,10 +44,13 @@ function createApp (source, object, routes, argv) {
|
||||
var defaults
|
||||
if (argv.static) {
|
||||
defaults = jsonServer.defaults({
|
||||
logger: !argv.quiet,
|
||||
static: path.join(process.cwd(), argv.static)
|
||||
})
|
||||
} else {
|
||||
defaults = jsonServer.defaults()
|
||||
defaults = jsonServer.defaults({
|
||||
logger: !argv.quiet
|
||||
})
|
||||
}
|
||||
|
||||
app.use(defaults)
|
||||
@ -79,6 +82,11 @@ module.exports = function (argv) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// noop log fn
|
||||
if (argv.quiet) {
|
||||
console.log = function () {}
|
||||
}
|
||||
|
||||
console.log()
|
||||
console.log(chalk.cyan(' \\{^_^}/ hi!'))
|
||||
|
||||
|
Reference in New Issue
Block a user