From 65349b7335b31dc7869616641776d6f8e29ee700 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 21 Mar 2018 10:08:38 +0330 Subject: [PATCH] disable build logs for test environments --- lib/builder/builder.mjs | 5 ++--- lib/common/utils.mjs | 16 +++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/builder/builder.mjs b/lib/builder/builder.mjs index 7ca34f801f..d37647b628 100644 --- a/lib/builder/builder.mjs +++ b/lib/builder/builder.mjs @@ -39,9 +39,8 @@ export default class Builder { this.webpackHotMiddleware = null this.filesWatcher = null this.customFilesWatcher = null - this.spinner = createSpinner({ - minimal: this.options.minimalCLI - }) + this.spinner = createSpinner({ minimal: this.options.minimalCLI }) + this.spinner.enabled = !this.options.test // Mute stats on dev this.webpackStats = this.options.dev ? false : this.options.build.stats diff --git a/lib/common/utils.mjs b/lib/common/utils.mjs index cd9b858f38..15d9411a4c 100644 --- a/lib/common/utils.mjs +++ b/lib/common/utils.mjs @@ -38,19 +38,21 @@ export const createSpinner = function ({ minimal = false }) { // Creare a minimal fallback for test and CI environments + const ctx = { enabled: true } + // eslint-disable-next-line no-console - const logger = (tag) => (...args) => console.log( + const createLogger = (tag, ctx) => (...args) => ctx.enabled && console.log( `[${(new Date().toISOString)()}]`, _.padEnd(`[${tag}]`, 10), ...args ) - return { - start: logger('START'), - fail: logger('FAIL'), - succeed: logger('SUCCESS'), - info: logger('INFO') - } + return Object.assign(ctx, { + start: createLogger('START', ctx), + fail: createLogger('FAIL', ctx), + succeed: createLogger('SUCCESS', ctx), + info: createLogger('INFO', ctx) + }) } export const encodeHtml = function encodeHtml(str) {