forked from ct-js/ct-js-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devSetup.gulpfile.js
74 lines (60 loc) · 1.91 KB
/
devSetup.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
'use strict';
const versions = require('./versions');
/* eslint no-console: 0 */
const spawnise = require('./node_requires/spawnise'),
gulp = require('gulp'),
minimist = require('minimist');
const fs = require('fs-extra');
const argv = minimist(process.argv.slice(2));
spawnise.logs = argv.logs || false; // gulp --logs
const cleanup = () => {
const fs = require('fs-extra');
return Promise.all([
fs.remove('./app/data/node_requires'),
fs.remove('./app/data/docs')
]);
};
const npmInstall = path => done => {
console.log(`Running 'npm install' for ${path}…`);
spawnise.spawn((/^win/).test(process.platform) ? 'npm.cmd' : 'npm', ['install'], {
cwd: path || './'
})
.then(done)
.catch(err => {
console.error(`'npm install' failed for ${path}`);
done(err);
});
};
const bakeDocs = async () => {
const npm = (/^win/).test(process.platform) ? 'npm.cmd' : 'npm';
await fs.remove('./app/data/docs/');
await spawnise.spawn(npm, ['run', 'build'], {
cwd: './docs'
});
await fs.copy('./docs/docs/.vuepress/dist', './app/data/docs/');
};
const updateGitSubmodules = () =>
spawnise.spawn('git', ['submodule', 'update', '--init', '--recursive']);
const makeVSCodeLaunchJson = () => {
const template = require('./.vscode/launch-template.json');
template.configurations.find(c => c.type === 'nwjs').nwjsVersion = versions.nwjs;
return fs.outputJson('./.vscode/launch.json', template, {
spaces: 4
});
};
const fetchNeutralino = async () => (await import('./gulpfile.mjs')).fetchNeutralino();
const defaultTask = gulp.series([
updateGitSubmodules,
gulp.parallel([
npmInstall('./'),
npmInstall('./app'),
npmInstall('./docs')
]),
cleanup,
gulp.parallel([
bakeDocs,
makeVSCodeLaunchJson,
fetchNeutralino
])
]);
gulp.task('default', defaultTask);