forked from HewlettPackard/hpe-oneview-hubot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
46 lines (38 loc) · 1.11 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
import gulp from 'gulp';
import babel from 'gulp-babel';
import tasks from 'gulp-task-listing';
import util from 'gulp-util';
import del from 'del';
// Add a task to render registered tasks when user types 'gulp help'
gulp.task('help', tasks);
gulp.task('default', ['help']);
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();
util.log('Copying templates to', dir);
return gulp.src('src/**/*.html').pipe(gulp.dest(dir))
}
function build() {
const dir = output();
util.log('Compiling javascript to', dir);
return gulp.src('src/**/*.js').pipe(babel()).pipe(gulp.dest(dir));
}
gulp.task('clean', function() {
const dir = output();
util.log('Removing destination', dir);
return del([dir], {force:true});
});
gulp.task('templates', ['clean'], templates);
gulp.task('build', ['templates'], function() { return build(); });
gulp.task('watch', ['build'], function () {
gulp.watch('src/**/*.js', ['build']);
});