From f37561252139e37e6c12811ff1bdf916ea7ef26c Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Wed, 11 Feb 2015 10:43:36 -0300 Subject: [PATCH] Add gulpfile and dependencies --- gulpfile.js | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 ++++ 2 files changed, 101 insertions(+) create mode 100644 gulpfile.js diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..3e3be6ad --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,95 @@ +/** + * @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'); + + +function ignoreerror() { + /* jshint ignore:start */ // using `this` in this context is weird + this.emit('end'); + /* jshint ignore:end */ +} + +var files = ['lib/**/*.js']; +var tests = ['test/**/*.js']; +var alljs = files.concat(tests); + + +/** + * testing + */ + +var testmocha = function() { + return gulp.src(tests).pipe(new mocha({ + reporter: 'spec' + })); +} + +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(['node_modules/.bin/plato -d report -r -l .jshintrc -t bitcore-node 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']); +}); diff --git a/package.json b/package.json index 6253ee67..1bffc6a6 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,11 @@ "xmlhttprequest": "~1.6.0" }, "devDependencies": { + "gulp": "^3.8.11", + "gulp-mocha": "^2.0.0", + "gulp-coveralls": "^0.1.3", + "gulp-jshint": "^1.9.2", + "gulp-shell": "^0.3.0", "chai": "*", "grunt": "~0.4.2", "grunt-cli": "~0.1.11", @@ -82,6 +87,7 @@ "grunt-mocha-test": "~0.8.1", "grunt-nodemon": "~0.2.0", "memdown": "^0.10.2", + "run-sequence": "^1.0.2", "should": "^2.1.1", "sinon": "^1.10.3" }