From 1a536a0ec9161361c83bdbd65a9f44408dce2eb8 Mon Sep 17 00:00:00 2001 From: Chris Jimenez Date: Fri, 23 Sep 2016 16:26:46 -0700 Subject: [PATCH] Set default reporter, log, and warn (#131) options.warn is called before a default is set if options.watchDelay is a thing. --- middleware.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/middleware.js b/middleware.js index a2fcd11cf..b40d5bd80 100644 --- a/middleware.js +++ b/middleware.js @@ -37,6 +37,9 @@ var defaultReporter = function(reporterOptions) { module.exports = function(compiler, options) { if(!options) options = {}; if(typeof options.watchOptions === "undefined") options.watchOptions = {}; + if(typeof options.reporter !== "function") options.reporter = defaultReporter; + if(typeof options.log !== "function") options.log = console.log.bind(console); + if(typeof options.warn !== "function") options.warn = console.warn.bind(console); if(typeof options.watchDelay !== "undefined") { // TODO remove this in next major version options.warn("options.watchDelay is deprecated: Use 'options.watchOptions.aggregateTimeout' instead"); @@ -53,9 +56,6 @@ module.exports = function(compiler, options) { options.filename = new RegExp("^[\/]{0,1}" + str + "$"); } } - if(typeof options.reporter !== "function") options.reporter = defaultReporter; - if(typeof options.log !== "function") options.log = console.log.bind(console); - if(typeof options.warn !== "function") options.warn = console.warn.bind(console); if(typeof compiler.outputPath === "string" && !path.isAbsolute(compiler.outputPath)) { throw new Error("`output.path` needs to be an absolute path or `/`."); }