From 99b9ace1ba0afdf508c1ebdae3b06ce1dbd9a0cb Mon Sep 17 00:00:00 2001 From: Sascha Depold Date: Sat, 4 Oct 2014 12:13:52 +0200 Subject: [PATCH] Add instantly failing reporter --- src/index.js | 1 + src/reporters/index.js | 5 +++-- src/reporters/instafail.js | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/reporters/instafail.js diff --git a/src/index.js b/src/index.js index ff79946..725a9b0 100644 --- a/src/index.js +++ b/src/index.js @@ -23,6 +23,7 @@ var jshintPlugin = function (opt) { // expose the reporters jshintPlugin.failReporter = reporters.fail; +jshintPlugin.instafailReporter = reporters.instafail; jshintPlugin.loadReporter = reporters.loadReporter; jshintPlugin.reporter = reporters.reporter; diff --git a/src/reporters/index.js b/src/reporters/index.js index a611f42..9ffd5b6 100644 --- a/src/reporters/index.js +++ b/src/reporters/index.js @@ -2,7 +2,8 @@ var PluginError = require('gulp-util').PluginError; var stream = require('../stream'); var _ = require('lodash'); -exports.failReporter = require('./fail'); +exports.fail = require('./fail'); +exports.instafail = require('./instafail'); exports.loadReporter = function (reporter) { // we want the function @@ -30,7 +31,7 @@ exports.reporter = function (reporter, reporterCfg) { reporterCfg = reporterCfg || {}; if (reporter === 'fail') { - return exports.failReporter(reporterCfg); + return exports.fail(reporterCfg); } var rpt = exports.loadReporter(reporter || 'default'); diff --git a/src/reporters/instafail.js b/src/reporters/instafail.js new file mode 100644 index 0000000..7bb48a3 --- /dev/null +++ b/src/reporters/instafail.js @@ -0,0 +1,13 @@ +var stream = require('../stream'); + +module.exports = function () { + return stream( + function through(file) { + if (file.jshint && !file.jshint.success && !file.jshint.ignored) { + process.exit(1); + } + }, + function flush() { + } + ); +};