This repository has been archived by the owner on Apr 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgulpfile.js
66 lines (56 loc) · 1.55 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
'use strict';
/* eslint-env node */
/* eslint-disable no-console, require-jsdoc */
const gulp = require('gulp');
const fs = require('fs');
const path = require('path');
const spawn = require('child_process').spawn;
const os = require('os');
global.config = {
src: './build-site',
dest: './build-prod',
};
const gulpTaskFiles = fs.readdirSync(path.join(__dirname, 'gulp-tasks'));
gulpTaskFiles.forEach((taskFile) => {
if (path.parse(taskFile).ext !== '.js') {
return;
}
const completePath = path.join(__dirname, 'gulp-tasks', taskFile);
if (fs.lstatSync(completePath).isFile()) {
require(completePath);
}
});
gulp.task('build', gulp.series([
'clean',
'ref-docs',
'jekyll:build',
gulp.parallel([
'styles',
'html',
'images',
'scripts',
'extras',
]),
'sw',
]));
gulp.task('serve', gulp.series(['ref-docs:watch', 'jekyll:serve']));
gulp.task('serve:fast', gulp.series(['ref-docs:watch', 'jekyll:serve-fast']));
function processPromiseWrapper(command, args) {
return new Promise((resolve, reject) => {
const process = spawn(command, args, {stdio: 'inherit'});
process.on('error', reject);
process.on('close', (code) => {
if (code === 0) {
resolve();
} else {
reject(`Error ${code} returned from ${command} ${args}`);
}
});
});
}
gulp.task('serve:prod', gulp.series(['build', () => {
const nodeCommand = os.platform() === 'win32' ? 'npm.cmd' : 'npm';
return processPromiseWrapper(nodeCommand,
['run', 'serve']);
}]));
gulp.task('default', gulp.parallel(['build']));