-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
78 lines (71 loc) · 1.88 KB
/
gulpfile.babel.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
72
73
74
75
76
77
78
import gulp from 'gulp';
import jasmineNode from 'gulp-jasmine-node';
import nodemon from 'gulp-nodemon';
import babel from 'gulp-babel';
import rename from 'gulp-rename';
import istanbul from 'gulp-babel-istanbul';
import injectModules from 'gulp-inject-modules';
import coveralls from 'gulp-coveralls';
gulp.task('pre-test', () => {
return gulp.src('src/*.js')
// Covering files
.pipe(istanbul({ includeUntested: true }))
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('run-tests', ['pre-test'], () => {
return gulp.src('tests/*.js')
.pipe(babel({
presets: ['es2015'],
plugins: ['transform-object-rest-spread']
}))
.pipe(injectModules())
// Run test assertions with jasmine-node
.pipe(jasmineNode({
timeout: 10000,
includeStackTrace: true,
color: true
}))
.pipe(istanbul.writeReports());
});
gulp.task('babelifyTestFiles', () => {
// rename test file to match /spec\.js$/i
const renameTestFile = (filename) => {
const replaceFunc = (match, p) => {
return String.prototype.toUpperCase.call(p);
};
return String.prototype.replace.call(filename, /-([a-z])/g, replaceFunc);
};
return gulp.src('tests/*.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(rename((path) => {
path.basename = `${renameTestFile(path.basename)}Spec`;
}))
.pipe(gulp.dest('spec'));
});
gulp.task('babelifySrcFiles', () => {
return gulp.src('src/*.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist'));
});
gulp.task('serve', ['babelifySrcFiles'], () => {
nodemon({
script: 'dist/app.js',
ext: 'js json html',
ignore: [
'node_modules/',
'.vscode/',
'/dist',
'/tests',
'gulpfile.babel.js'],
tasks: ['babelifySrcFiles']
});
});
gulp.task('coverage', ['run-tests'], () => {
return gulp.src('coverage/lcov.info')
.pipe(coveralls());
});