-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
47 lines (36 loc) · 1.07 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
const gulp = require('gulp');
const tasks = require('gulp-task-listing');
const log = require('fancy-log');
const del = require('del');
function output() {
var fs = require('fs');
if (fs.existsSync('../hubot')) {
return '../hubot/scripts';
}
if (fs.existsSync('./hubot')) {
return './hubot/scripts';
}
return 'dist';
}
function templates() {
const dir = output();
log('Copying templates to', dir);
return gulp.src('src/**/*.html').pipe(gulp.dest(dir))
}
function build() {
const dir = output();
log('Copying javascript to', dir);
return gulp.src('src/**/*.js').pipe(gulp.dest(dir));
}
function watchFiles() {
gulp.watch("src/**/*.js", build);
}
gulp.task('clean', function() {
const dir = output();
log('Removing destination', dir);
return del([dir], {force:true});
});
gulp.task('templates', gulp.series('clean', function() { return templates(); }));
gulp.task('build', gulp.series('templates', function() { return build(); }));
gulp.task('watch', gulp.series('build', function () { return watchFiles(); }));
gulp.task('help', tasks);