-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
52 lines (47 loc) · 1.23 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
/*
* @flow
* Copyright (c) 2017 Daniel Ennis (Aikar) - MIT License - http://opensource.org/licenses/MIT
*/
const gulp = require('gulp');
require('gulp-bash-completion')(gulp);
const babel = require('gulp-babel');
const license = require('gulp-license-check');
const flow = require('gulp-flowtype');
const umd = require('gulp-umd');
const sourcemaps = require('gulp-sourcemaps');
const scripts = 'src/**/*.js';
gulp.task('build', () => {
return gulp.src(scripts, {base: 'src'})
.pipe(license({
path: '.license-header',
blocking: false,
logInfo: false,
logError: true
}))
.pipe(flow({
all: false,
weak: false,
beep: true,
abort: true,
}))
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(umd())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
gulp.task('prepublish', ['build']);
gulp.task('default', ['build'], () => {
require('gulp-watch')(scripts, () => scheduleTask('build'));
});
// =====================
const scheduledTasks = {};
function scheduleTask(task, time) {
if (scheduledTasks[task]) {
clearTimeout(scheduledTasks[task]);
}
scheduledTasks[task] = setTimeout(function () {
delete scheduledTasks[task];
gulp.start(task);
}, time);
}