This repository has been archived by the owner on Mar 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGulpfile.js
75 lines (66 loc) · 1.71 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
72
73
74
75
'use strict';
const gulp = require('gulp');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const ava = require('gulp-ava');
const documentation = require('gulp-documentation');
const exec = require('child_process').exec;
const rimraf = require('rimraf');
const packageJson = require('./package.json');
const CONFIG = {
'js': {
'src': './src/**/*.js',
'dst': './lib'
},
'test': {
'js': {
'trgt': './test/**/*.js'
}
},
'documentation': {
'js': {
'dst': './documentation'
}
}
};
function clean(cb) {
return rimraf(CONFIG.js.dst, (err) => {
cb(err);
});
}
function flowcopy(cb) {
return exec('npm run flow:copy', (err) => {
cb(err);
});
}
function transpile(cb) {
return gulp.src([CONFIG.js.src])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(babel())
.pipe(gulp.dest(CONFIG.js.dst))
.on('end', cb);
}
function test(cb) {
return gulp.src([CONFIG.test.js.trgt])
.pipe(ava({
'verbose': false,
'silent': false,
'nyc': false
}))
.on('end', cb);
}
function doc(cb) {
return gulp.src(CONFIG.js.src)
.pipe(documentation('md', {}, {
'name': packageJson.name,
'version': packageJson.version
}))
.pipe(gulp.dest(CONFIG.documentation.js.dst))
.on('end', cb);
}
gulp.task('compile', gulp.series(clean, transpile, flowcopy));
gulp.task('develop', () => gulp.watch(['package.json', CONFIG.js.src], gulp.series(clean, transpile, flowcopy)));
gulp.task('test', test);
gulp.task('documentation', doc);