From feb1cab7ef02b4db265280ff19cce7f5c0f8d290 Mon Sep 17 00:00:00 2001 From: Addy Osmani Date: Mon, 15 Jun 2015 10:26:18 +0100 Subject: [PATCH] gulpfile: add jscs task & integrate This change added a `gulp jscs` task and integrates it into both the `default` and `tests` pipelines. This means if code does not pass, it will fail the build. --- gulpfile.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f1233f2b..2da8d6c3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -61,6 +61,14 @@ gulp.task('jshint', function () { .pipe($.if(!browserSync.active, $.jshint.reporter('fail'))); }); +// Lint JavaScript code style +gulp.task('jscs', function () { + return gulp.src('src/**/*.js') + .pipe(reload({stream: true, once: true})) + .pipe($.jscs()) + .pipe($.if(!browserSync.active, $.jshint.reporter('fail'))); +}); + // ***** Production build tasks ****** // // Optimize Images @@ -201,7 +209,7 @@ gulp.task('clean', del.bind(null, ['dist', '.publish'], {dot: true})); gulp.task('default', ['clean', 'mocha'], function (cb) { runSequence( 'styles', - ['jshint', 'scripts', 'styles', 'assets', 'pages', 'demos', 'templates', + ['jshint', 'jscs', 'scripts', 'styles', 'assets', 'pages', 'demos', 'templates', 'images'], cb); }); @@ -213,7 +221,7 @@ gulp.task('mocha', ['styles'], function () { .pipe($.mochaPhantomjs({reporter: 'list'})); }); -gulp.task('test', ['jshint', 'mocha']); +gulp.task('test', ['jshint', 'jscs', 'mocha']); gulp.task('test:visual', function() { browserSync({