From 8f3ef79e0215ae6cf89394d43012a4b9d06f2cb2 Mon Sep 17 00:00:00 2001 From: Simon Stamcar Date: Thu, 12 Jan 2017 18:41:15 +0100 Subject: [PATCH] Include error messages from server in output --- index.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index c01bf57..9cf9270 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,8 @@ FlowStatusWebpackPlugin.prototype.apply = function(compiler) { waitingForFlow = true; // this will start a flow server if it was not running - shell.exec(flow + ' status --color always', {silent: true}, function(code, stdout, stderr) { + // quiet option will suppress any "server starting" messages + shell.exec(flow + ' status --color always --quiet', {silent: true}, function(code, stdout, stderr) { var hasErrors = code !== 0; var cb = hasErrors ? errorCb : successCb; waitingForFlow = false; @@ -59,10 +60,19 @@ FlowStatusWebpackPlugin.prototype.apply = function(compiler) { onSuccess(stdout); cb(); - }, function error(stdout) { - onError(stdout); + }, function error(stdout, stderr) { + var msg = stdout; + // In case flow server got killed. + if (!stdout && !stderr) { + stderr = 'Unknown error!'; + } + if (stderr) { + msg = (msg ? msg + '\n' : '') + 'flow server: ' + stderr; + } - flowError = new Error(stdout); + onError(msg); + + flowError = new Error(msg); // Here we don't pass error to callback because // webpack-dev-middleware would just throw it // and cause webpack dev server to exit with