-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Creates 'paths' object * Cleans up formatting * Adds `spec` to lint task * Remove jscs from dev task
- Loading branch information
John F. Mercer
committed
Aug 21, 2015
1 parent
00ceb49
commit 7b4d2ff
Showing
1 changed file
with
32 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,57 @@ | ||
var gulp = require('gulp'); | ||
var jshint = require('gulp-jshint'); | ||
var jscs = require('gulp-jscs'); | ||
var jasmine = require('gulp-jasmine'); | ||
var istanbul = require('gulp-istanbul'); | ||
var gulp = require('gulp'); | ||
var jshint = require('gulp-jshint'); | ||
var jscs = require('gulp-jscs'); | ||
var jasmine = require('gulp-jasmine'); | ||
var istanbul = require('gulp-istanbul'); | ||
|
||
var paths = { | ||
'spec' : 'spec/**/*.js', | ||
'lib' : 'lib/**/*.js' | ||
} | ||
|
||
// Proofread the code | ||
gulp.task('lint', function() { | ||
return gulp.src(['lib/**/*.js']) | ||
return gulp.src([paths.lib, paths.spec]) | ||
.pipe(jshint()) | ||
.pipe(jshint.reporter('default')) | ||
.pipe(jshint.reporter('fail')); | ||
}); | ||
|
||
// Run the unit tests without any coverage calculations | ||
gulp.task('test', function() { | ||
return gulp.src(['spec/**/*.js']) | ||
return gulp.src([paths.spec]) | ||
.pipe(jasmine()); | ||
}); | ||
|
||
// Task that calculates the unit test coverage for the module | ||
gulp.task('coverage', function() { | ||
return gulp.src('lib/**/*.js') | ||
.pipe(istanbul()) | ||
.pipe(istanbul.hookRequire()) | ||
.on('finish', function() { | ||
gulp.src(['spec/**/*.js']) | ||
.pipe(jasmine()) | ||
.pipe(istanbul.writeReports({ | ||
dir: 'build/coverage', | ||
reportOpts: {dir: 'build/coverage'} | ||
})); | ||
}); | ||
return gulp.src(paths.lib) | ||
.pipe(istanbul()) | ||
.pipe(istanbul.hookRequire()) | ||
.on('finish', function() { | ||
gulp.src([paths.spec]) | ||
.pipe(jasmine()) | ||
.pipe(istanbul.writeReports({ | ||
dir: 'build/coverage', | ||
reportOpts: {dir: 'build/coverage'} | ||
})); | ||
}); | ||
}); | ||
|
||
gulp.task('style', function() { | ||
return gulp.src('lib/**/*.js') | ||
return gulp.src(paths.lib) | ||
.pipe(jscs()); | ||
}); | ||
|
||
gulp.task('default', ['lint', 'style', 'test']); | ||
|
||
// On change to JavaScript files, run the default task | ||
gulp.task('dev', ['default'], function() { | ||
gulp.watch(['spec/**/*.js', 'lib/**/*.js'], ['default']); | ||
// alias watch === dev | ||
gulp.task('watch', ['dev']); | ||
|
||
// On change to JavaScript files, run lint & test tasks | ||
// Do NOT run default: the style task breaks dev | ||
gulp.task('dev', ['lint', 'test'], function() { | ||
gulp.watch([paths.spec, paths.lib], ['lint', 'test']); | ||
}); | ||
|
||
gulp.task('ci', ['default']); |