forked from darkreader/darkreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
78 lines (70 loc) · 1.85 KB
/
Copy pathbuild.js
File metadata and controls
78 lines (70 loc) · 1.85 KB
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
// @ts-check
const bundleAPI = require('./bundle-api');
const bundleCSS = require('./bundle-css');
const bundleHTML = require('./bundle-html');
const bundleJS = require('./bundle-js');
const bundleLocales = require('./bundle-locales');
const clean = require('./clean');
const copy = require('./copy');
const reload = require('./reload');
const codeStyle = require('./code-style');
const zip = require('./zip');
const {runTasks} = require('./task');
const {log} = require('./utils');
const standardTask = [
clean,
bundleJS,
bundleCSS,
bundleHTML,
bundleLocales,
copy,
];
async function release() {
log.ok('RELEASE');
try {
await runTasks([...standardTask, codeStyle, zip], {debug: false, watch: false});
log.ok('MISSION PASSED! RESPECT +');
} catch (err) {
log.error(`MISSION FAILED!`);
process.exit(13);
}
}
async function debug({watch}) {
log.ok('DEBUG');
try {
await runTasks(standardTask, {debug: true, watch: watch});
if (watch) {
standardTask.forEach((task) => task.watch());
reload({type: reload.FULL});
log.ok('Watching...');
} else {
log.ok('MISSION PASSED! RESPECT +');
}
} catch (err) {
log.error(`MISSION FAILED!`);
process.exit(13);
}
}
async function api() {
log.ok('API');
try {
await runTasks([bundleAPI], {debug: false, watch: false});
log.ok('MISSION PASSED! RESPECT +');
} catch (err) {
log.error(`MISSION FAILED!`);
process.exit(13);
}
}
async function run() {
const args = process.argv.slice(2);
if (args.includes('--release')) {
await release();
}
if (args.includes('--debug')) {
await debug({watch: args.includes('--watch')});
}
if (args.includes('--api')) {
await api();
}
}
run();