-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (57 loc) · 1.84 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var gulp = require( 'gulp' );
var mocha = require( 'gulp-mocha' );
var cover = require( 'gulp-coverage' );
var karma = require( 'karma' ).server;
var jshint = require( 'gulp-jshint' );
var jscs = require( 'gulp-jscs' );
var lintspaces = require( 'gulp-lintspaces' );
var exec = require( 'child_process' ).exec;
gulp.task('bower-install', function( cb ) {
exec( 'bower install', function ( err, stdout, stderr ) {
cb( err );
});
});
gulp.task('npm-install', function( cb ) {
exec( 'npm install', function ( err, stdout, stderr ) {
cb( err );
});
});
gulp.task('test-node', [ 'lint', 'codestyle', 'npm-install' ], function() {
return gulp.src( 'test/specs/**/*.js', { read: false } )
.pipe( cover.instrument({
pattern: [ 'src/**/*' ],
debugDirectory: 'coverage/node/debug'
}) )
.pipe( mocha() )
.pipe( cover.report({
outFile: 'coverage/node/coverage.html'
}) );
});
gulp.task('test-browser', [ 'lint', 'codestyle', 'bower-install' ], function( cb ) {
karma.start({
configFile: __dirname + '/test/karma.conf.js',
singleRun: true
}, cb);
});
gulp.task('test-amd', [ 'lint', 'codestyle', 'bower-install' ], function( cb ) {
karma.start({
configFile: __dirname + '/test/karma.conf.amd.js',
singleRun: true
}, cb);
});
gulp.task('lint', [ 'npm-install' ], function() {
return gulp.src( [ 'src/**/*.js' ] )
.pipe( jshint() )
.pipe( jshint.reporter( 'default' ) );
});
gulp.task('codestyle', [ 'npm-install' ], function() {
return gulp.src( [ 'src/**/*.js' ] )
.pipe(jscs())
.pipe(lintspaces({
editorconfig: '.editorconfig',
ignores: [
'js-comments'
]
}));
});
gulp.task('default', [ 'test-node', 'test-browser', 'test-amd' ]);