-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
48 lines (43 loc) · 1.43 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
const gulp = require("gulp"); // eslint-disable-line no-undef
const fs = require("fs-extra"); // eslint-disable-line no-undef
const { execSync } = require('child_process'); // eslint-disable-line no-undef
const minimist = require('minimist'); // eslint-disable-line no-undef
const osArchFinder = require("./backend/lib/os_arch"); // eslint-disable-line no-undef
gulp.task("git_switch", async () => {
try {
fs.statSync('.git.open');
fs.moveSync('.git', '.git.keep');
fs.moveSync('.git.open', '.git');
} catch(e) {
fs.moveSync('.git', '.git.open');
fs.moveSync('.git.keep', '.git');
}
});
gulp.task("exec", async () => {
const commands = [];
if (osArchFinder()[0] === "win") {
commands.push("chcp 65001");
}
commands.push("npm run js_build");
commands.push("npm run css_build");
commands.push("electron .");
execSync(commands.join(" && "), {stdio: 'inherit'});
});
gulp.task("build", async () => {
const [os, arch_abbr, pf, arch] = getArchOption();
const commands = [
"npm run lint",
"npm run js_build",
"npm run css_build"
];
const packege_cmd = `electron-builder --${os} --${arch} --config ./build_${os}.js`;
console.log(packege_cmd);
commands.push(packege_cmd);
execSync(commands.join(" && "), {stdio: 'inherit'});
});
function getArchOption() {
const options = minimist(process.argv.slice(2), { // eslint-disable-line no-undef
string: 'arch'
});
return osArchFinder(options.arch);
}