Skip to content

Commit

Permalink
Set default reporter, log, and warn (#131)
Browse files Browse the repository at this point in the history
options.warn is called before a default is set if options.watchDelay is a thing.
  • Loading branch information
Chris Jimenez authored and SpaceK33z committed Sep 23, 2016
1 parent c3d0ee5 commit 1a536a0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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 `/`.");
}
Expand Down

0 comments on commit 1a536a0

Please sign in to comment.