-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
74 lines (65 loc) · 1.87 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
const {series, src, dest, symlink} = require('gulp');
const watch = require('gulp-watch');
const {spawn} = require('child_process');
const del = require('del');
// from https://stackoverflow.com/a/50396702/682095
async function pipe(tap, sink) {
return new Promise((resolve, reject) => {
tap.pipe(sink, {end: false});
tap.on('end', resolve);
tap.on('error', reject);
});
}
function spawnPromise(...args) {
return new Promise(resolve => {
const proc = spawn(...args);
proc.on('close', resolve);
});
}
function clean() {
return del(['build/**/*']);
}
function npm() {
return spawnPromise('npm', ['install', '--ignore-scripts'], {stdio: 'inherit', cwd: './build'});
}
async function setup() {
await pipe(
src('node_modules/semantic-ui/**/*'),
dest('build/')
);
await pipe(
src('theme/theme.config'),
symlink('build/src/')
);
await pipe(
src('theme/indico/**/*'),
dest('build/themes/indico')
);
// These overrides are needed
await pipe(
src('build/src/themes/default/elements/{icon,flag,divider,step}.overrides'),
dest('build/themes/indico/elements/')
);
await pipe(
src('build/src/themes/default/modules/{checkbox,dropdown,accordion,transition,rating}.overrides'),
dest('build/themes/indico/modules/')
);
await pipe(
src('semantic.json'),
symlink('build/')
);
}
function _build() {
return spawnPromise('gulp', ['build'], {stdio: 'inherit', cwd: './build'});
}
async function _watch() {
return watch('theme/**/*.{config,variables,overrides}', async () => {
await _build();
});
}
const build = series(setup, npm, _build);
exports.rebuild = series(clean, build);
exports.build = build;
exports.watch = series(setup, npm, _watch);
exports.clean = clean;
exports.default = build;