-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstart.js
52 lines (45 loc) · 1.12 KB
/
start.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
// Usage: execute `$ npm run start` inside your shell.
const util = require('util');
const exec = util.promisify(
require('child_process').exec
);
/**
* @param {string} command
*/
async function executeCommand(command) {
console.info(`Executing command: ${command}`);
try {
const { stdout, stderr } = await exec(command);
stderr ? console.error(`Command stderr: ${stderr}`) : console.log(`Command stdout: ${stdout}`);
} catch(e) {
console.error(e);
}
}
async function cleanBuildTarget() {
await executeCommand('npm run clean');
}
async function buildProject() {
await executeCommand('npm run build');
}
/*
async function openBrowser() {
switch (process.platform) {
case 'darwin':
await executeCommand('npm run open_browser_macos');
break;
case 'win32':
await executeCommand('npm run open_browser_win');
break;
case 'linux':
await executeCommand('npm run open_browser_linux');
break;
default:
console.error('Unsupported platform!');
}
} */
async function main() {
await cleanBuildTarget();
await buildProject();
// await openBrowser();
}
main();