Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
fixes #126: gulp - throw/non-throw versions of linting tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Grupp committed Feb 18, 2015
1 parent 5c188f5 commit cb8c99a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
1 change: 1 addition & 0 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"gulp": "^3.8.10",
"gulp-angular-filesort": "^1.0.4",
"gulp-autoprefixer": "^1.0.1",
"gulp-if": "^1.2.5",
"gulp-inject": "^1.1.1",
"gulp-jscs": "^1.4.0",
"gulp-jshint": "^1.9.0",
Expand Down
2 changes: 1 addition & 1 deletion app/templates/gulp_tasks/building.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var $ = require('gulp-load-plugins')();
var del = require('del');
var vinylPaths = require('vinyl-paths');

gulp.task('build', ['linting', 'build-app', 'build-templates', 'build-assets'], function () {
gulp.task('build', ['linting-throw', 'build-app', 'build-templates', 'build-assets'], function () {
return gulp.src(paths.dist + '/**/*')
.pipe($.size({title: 'build', gzip: true}));
});
Expand Down
49 changes: 32 additions & 17 deletions app/templates/gulp_tasks/linting.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,40 @@ var $ = require('gulp-load-plugins')();

// all linting tasks
gulp.task('linting', ['jshint', 'jscs', 'jsonlint']);
gulp.task('linting-throw', ['jshint-throw', 'jscs-throw', 'jsonlint-throw']);

// check for jshint errors
gulp.task('jshint', function () {
return gulp.src(paths.jsFiles)
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.jshint.reporter('fail'));
});
var jshint = function (fail) {
return function () {
return gulp.src(paths.jsFiles)
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.if(fail, $.jshint.reporter('fail')));
};
};
gulp.task('jshint', jshint());
gulp.task('jshint-throw', jshint(true));

// check for jscs errors
gulp.task('jscs', function () {
return gulp.src(paths.jsFiles)
.pipe($.jscs());
});
var jscs = function () {
return function () {
return gulp.src(paths.jsFiles)
.pipe($.jscs());
};
};
gulp.task('jscs', jscs());
gulp.task('jscs-throw', jscs(true));

gulp.task('jsonlint', function () {
return gulp.src(paths.jsonFiles)
.pipe($.jsonlint())
.pipe($.jsonlint.reporter(function (file) {
throw new Error(file.path + '\n' + file.jsonlint.message);
}));
});
// check for jsonlint errors
var jsonlint = function (fail) {
var failReporter = function (file) {
throw new Error(file.path + '\n' + file.jsonlint.message);
};
return function () {
return gulp.src(paths.jsonFiles)
.pipe($.jsonlint())
.pipe($.jsonlint.reporter(fail ? failReporter : undefined));
};
};
gulp.task('jsonlint', jsonlint());
gulp.task('jsonlint-throw', jsonlint(true));
2 changes: 1 addition & 1 deletion app/templates/gulp_tasks/watching.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var createConnectServer = function (paths) {
};

// WATCH
gulp.task('watch', ['serve'], function () {
gulp.task('watch', ['serve', 'linting'], function () {
$.livereload.listen();

gulp.watch([
Expand Down

0 comments on commit cb8c99a

Please sign in to comment.