/** * @file gulpfile.js * * Defines tasks that can be run on gulp. * * Summary: */ 'use strict'; var gulp = require('gulp'); var coveralls = require('gulp-coveralls'); var jshint = require('gulp-jshint'); var mocha = require('gulp-mocha'); var shell = require('gulp-shell'); var files = ['lib/**/*.js']; var tests = ['test/**/*.js']; var alljs = files.concat(tests); function ignoreError() { /* jshint ignore:start */ // using `this` in this context is weird this.emit('end'); /* jshint ignore:end */ } var testMocha = function() { return gulp.src(tests).pipe(new mocha({ reporter: 'spec' })); }; /** * Testing */ gulp.task('test', testMocha); gulp.task('test:nofail', function() { return testMocha().on('error', ignoreError); }); /** * Code quality and documentation */ gulp.task('lint', function() { return gulp.src(alljs) .pipe(jshint()) .pipe(jshint.reporter('default')); }); gulp.task('plato', shell.task(['plato -d report -r -l .jshintrc -t bitcore lib'])); gulp.task('coverage', shell.task(['node_modules/.bin/./istanbul cover node_modules/.bin/_mocha -- --recursive'])); gulp.task('coveralls', ['coverage'], function() { gulp.src('coverage/lcov.info').pipe(coveralls()); }); /** * Watch tasks */ gulp.task('watch:test', function() { // TODO: Only run tests that are linked to file changes by doing // something smart like reading through the require statements return gulp.watch(alljs, ['test']); }); gulp.task('watch:coverage', function() { // TODO: Only run tests that are linked to file changes by doing // something smart like reading through the require statements return gulp.watch(alljs, ['coverage']); }); gulp.task('watch:lint', function() { // TODO: Only lint files that are linked to file changes by doing // something smart like reading through the require statements return gulp.watch(alljs, ['lint']); }); /* Default task */ gulp.task('default', ['lint', 'coverage'], function() { });