-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
71 lines (58 loc) · 1.83 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
66
67
68
69
70
71
var gulp = require('gulp'),
path = require('path'),
config = {
paths: {
dest: 'dist',
scripts: ['src/*.js', 'src/**/*.js'],
tests: {
unit: ['test/*.spec.js', 'test/**/*.spec.js']
}
},
eslint: {
rcPath: path.join(__dirname + '/.eslintrc')
}
},
args = require('yargs')(process.argv)
.string('only')
.default('only', undefined)
.argv;
gulp.task('scripts:lint', function() {
var eslint = require('gulp-eslint');
return gulp.src(config.paths.scripts)
.pipe(eslint({
configFile: config.eslint.rcPath
}))
.pipe(eslint.format())
.pipe(eslint.failOnError())
});
gulp.task('scripts:transpile', ['scripts:lint'], function() {
var babel = require('gulp-babel');
return gulp.src(config.paths.scripts, {base: './src'})
.pipe(babel({
optional: ['runtime']
}))
.on('error', function(err) {
console.error(err);
})
.pipe(gulp.dest(config.paths.dest));
});
gulp.task('scripts', ['scripts:transpile']);
gulp.task('scripts:watch', function() {
gulp.watch(config.paths.scripts, ['scripts']);
});
gulp.task('test:unit', ['scripts'], function() {
var mocha = require('gulp-mocha');
return gulp.src(config.paths.tests.unit, {read: false})
.pipe(mocha({
reporter: 'spec',
ui: 'tdd',
grep: args.only,
require: ['should', path.join(__dirname, '/test/babelRegister')]
}));
});
gulp.task('test:unit:watch', function() {
gulp.watch(config.paths.scripts, ['test:unit']);
gulp.watch(config.paths.tests.unit, ['test:unit']);
});
gulp.task('test', ['test:unit']);
gulp.task('build', ['scripts:transpile']);