-
Notifications
You must be signed in to change notification settings - Fork 132
/
gulpfile.babel.js
81 lines (65 loc) · 2.1 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
79
80
81
/**
* Copyright (c) 2016 Hideki Shiro
*/
/* eslint-disable no-process-env, global-require */
import path from 'path';
import assert from 'assert';
import gulp from 'gulp';
import del from 'del';
import babel from 'gulp-babel';
import mocha from 'gulp-mocha';
import eslint from 'gulp-eslint';
import browserify from 'browserify';
import source from 'vinyl-source-stream';
// Clean
gulp.task('clean', done => {
return del(['build', 'npm-debug.log', '!*/.gitkeep'], done);
});
// Lint
gulp.task('lint', () => {
return gulp.src(['src/**/*.js', 'test/**/*.js', 'gulpfile.babel.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
// Build
gulp.task('build:src', () => {
return gulp.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('build/src/'));
});
gulp.task('build:res', () => {
return gulp.src('fonts/**/*')
.pipe(gulp.dest('build/fonts/'));
});
gulp.task('build:test:src', () => {
return gulp.src('test/**/*.js')
.pipe(babel())
.pipe(gulp.dest('build/test/'));
});
gulp.task('build:test:browser', () => {
return browserify('./build/test/browser.js')
.bundle()
.pipe(source('browser.js'))
.pipe(gulp.dest('build/test'));
});
gulp.task('build', gulp.series('build:src', 'build:res', 'build:test:src', 'build:test:browser'));
// Test
gulp.task('version-check', done => {
const packageVer = require('./package.json').version;
const tagVer = process.env.TRAVIS_TAG;
if (tagVer) {
assert.equal(packageVer, tagVer, `Package version and tagged version are mismatched. Package version is ${packageVer}, but tagged version is ${tagVer}`);
}
done();
});
gulp.task('test', gulp.series(gulp.parallel('build', 'lint', 'version-check'), () => {
return gulp.src('build/test/index.js')
.pipe(mocha());
}));
gulp.task('test:html', gulp.series(gulp.parallel('build', 'lint', 'version-check'), () => {
const reporter = path.join(__dirname, './build/test/html-reporter.js');
const dest = path.join(__dirname, './build/test/result.html');
return gulp.src('build/test/index.js')
.pipe(mocha({ reporter, reporterOptions: { dest } }));
}));