disable build logs for test environments

This commit is contained in:
Pooya Parsa 2018-03-21 10:08:38 +03:30
parent 7e91ae1d13
commit 65349b7335
2 changed files with 11 additions and 10 deletions

View File

@ -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

View File

@ -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) {