-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
91 lines (84 loc) · 5.84 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//========================================================================================
// NightOwl GUI Gulpfile
//========================================================================================
"use strict";
const gulp = require('gulp');
const gp = require('gulp-load-plugins')();
const del = require('del');
const spawn = require('child_process').spawn;
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// Handy Paths:
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
const paths = {
stylusIncludeDirs: ['bower_components/nog-css-reset', 'src/styl'],
stylFiles: ['test/webapp/styl/*.styl'],
htmlFiles: ['test/webapp/*.html'],
build: {
cssDir: '_build/webapp/css'
}
};
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// Stylus Tasks:
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
gulp.task('stylus', () => {
return gulp.src(paths.stylFiles)
.pipe(gp.plumber())
.pipe(gp.stylus({
paths: paths.stylusIncludeDirs
}))
.pipe(gulp.dest(paths.build.cssDir));
});
gulp.task('release:stylus', () => {
return gulp.src(paths.stylFiles)
.pipe(gp.stylus())
.pipe(gulp.dest(paths.build.cssDir));
});
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// Building and Releasing Tasks:
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
const buildTasks = ['stylus'];
const releaseTasks = [];
for (const task of buildTasks) {
releaseTasks.push('release:' + task);
}
gulp.task('build', gulp.series(buildTasks));
gulp.task('release', gulp.series(releaseTasks));
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// Watching and Live Reloading Tasks:
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
gulp.task('watch:html', () => {
gulp.watch(paths.htmlFiles).on('change', function(file) {
gp.livereload.changed(file);
});
});
function startLiveReload(done) {
gp.livereload.listen();
done();
}
gulp.task('watch', gulp.series(startLiveReload, gulp.parallel('watch:html')));
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// Testing Tasks:
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
gulp.task('runTestServer', function(done) {
const child = spawn('node', ['test/server.js']);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
child.on('close', code => {
console.info(`Test server child process exited with code ${code}.`);
done();
});
});
gulp.task('test', gulp.series('build', gulp.parallel('runTestServer', 'watch')));
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// Cleaning Tasks:
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
gulp.task('clean', function(done) {
return del(['./_build/']);
});
gulp.task('deep-clean', gulp.series('clean', function(done) {
return del(['./bower_components/', './node_modules/']);
}));
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
// Default Task:
//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
gulp.task('default', gulp.series('test'));