-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
71 lines (57 loc) · 2.3 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
/* eslint-disable global-require */
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const istanbul = require('gulp-istanbul');
const mocha = require('gulp-mocha');
const jsdoc = require('gulp-jsdoc3');
const runSequence = require('run-sequence');
const srcCode = ['./src/**/*.js'];
const specs = ['./test/**/*_spec.js'];
const lintedFiles = ['*.js', './test/**/*.js', '!./test/docs/**/*.js'].concat(srcCode);
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
gulp.task('build', ['babelify']);
// No real need to have a minify set for now, let dev and prod builds be the same
gulp.task('babelify', () => gulp.src(srcCode)
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist')));
gulp.task('lint', () => gulp.src(lintedFiles)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError()));
gulp.task('watch-lint', () => {
runSequence('lint', () => {
gulp.watch(lintedFiles, ['lint']);
});
});
gulp.task('pre-test', () => {
// Everything file loaded from here uses babel with .babelrc
require('babel-core/register'); // https://babeljs.io/docs/usage/require/
return gulp.src(srcCode)
// Covering files (we use isparta for babel support)
.pipe(istanbul({instrumenter: require('isparta').Instrumenter}))
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('test', ['pre-test'], () => {
// Everything file loaded from here uses babel with .babelrc
require('babel-core/register'); // https://babeljs.io/docs/usage/require/
return gulp.src(specs, {read: false})
.pipe(mocha())
.pipe(istanbul.writeReports())
// Enforce a coverage of at least 90%
.pipe(istanbul.enforceThresholds({thresholds: {global: 75}}));
});
// We do this over using include/exclude to make everything feel gulp-like!
gulp.task('doc', (cb) => {
const config = require('gulp-jsdoc3/dist/jsdocConfig.json');
config.templates.systemName = 'temper';
gulp.src(['README.md'].concat(srcCode).concat(['!**/*-cli.js']), {read: false})
.pipe(jsdoc(config, cb));
});
gulp.task('default', (cb) => {
runSequence('build', 'doc', cb);
});