-
-
Notifications
You must be signed in to change notification settings - Fork 131
/
devSetup.gulpfile.js
82 lines (67 loc) · 2.09 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
75
76
77
78
79
80
81
82
'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 || './',
shell: true
})
.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',
shell: true
});
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 fetchPatrons = async () => {
const {patronsCache} = await import('./gulpfile.mjs');
return patronsCache;
};
const defaultTask = gulp.series([
updateGitSubmodules,
gulp.parallel([
npmInstall('./'),
npmInstall('./app'),
npmInstall('./docs')
]),
cleanup,
gulp.parallel([
bakeDocs,
makeVSCodeLaunchJson,
fetchPatrons,
fetchNeutralino
])
]);
gulp.task('default', defaultTask);