Last active
August 14, 2016 08:34
-
-
Save christian-acuna/ef089987bee9be8ae9801b3b288d7f7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//npm i gulp -D | |
//in gulpfile.js | |
var gulp = require('gulp'); | |
//npm i gulp-jshint gulp-jscs -D | |
//in gulpfile | |
var jshint = require('gulp-jshint'); | |
var jscs = require('gulp-jscs'); | |
//$ npm i -D gulp-util | |
var util = require('gulp-util'); | |
//$ npm i -D gulp-print | |
var gulpprint = require('gulp-print'); | |
//$ npm i -D gulp-if yargs | |
var gulpif = require('gulp-if'); | |
var args = require('yargs').argv; | |
var paths = { | |
js : ['*.js', 'src/**/*.js'] | |
}; | |
//var jsFiles = ['*.js', 'src/**/*.js']; // optional way instead of paths var | |
gulp.task('vet', function() { | |
log('Analyzing source with JSHint and JSCS'); | |
return gulp | |
.src(paths.js) | |
.pipe(gulpif(args.verbose, gulpprint())) //run with $ gulp vet --verbose | |
.pipe(jscs()) | |
.pipe(jscs.reporter()) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('jshint-stylish', { | |
verbose: true | |
})) | |
.pipe(jshint.reporter('fail')); | |
}); | |
//need to get jshint-stylish | |
//$ npm i jshint -D | |
//$ npm i jshint-stylish -D | |
var util = require('gulp-util'); | |
//////////// | |
function log(msg) { | |
if (typeof(msg) === 'object') { | |
for (var item in msg) { | |
if (msg.hasOwnProperty(item)) { | |
util.log(util.colors.blue(msg[item])); | |
} | |
} | |
} else { | |
util.log(util.colors.blue(msg)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment