This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
EmiBuild.js
75 lines (63 loc) · 2.42 KB
/
EmiBuild.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
// Don't run this file manually, use `npm run emi:build` or `npm run emi:build:linux`.
const COMPILED_NAME = 'Server.exe';
/* eslint-disable @typescript-eslint/no-var-requires */
const { exec } = require('pkg');
const fs = require('fs-extra');
const chalk = require('chalk');
// Build process ------------------------------
if (!fs.existsSync('build')) {
console.log(chalk.blue('creating build/...'));
fs.mkdirSync('build');
}
console.log(chalk.blue('compiling executable...'));
(async () => {
await exec([
'dist/src/main.js',
'--target',
'host',
'--output',
`build/${COMPILED_NAME}`,
]);
console.log(chalk.green(`compiled server to: build/${COMPILED_NAME}`));
// I should find a better way to do this.
console.log(chalk.blue('copying dist/* to build/...'));
fs.copy('dist/', 'build/', function (err) {
if (err) return console.error(err);
console.log(chalk.green('... done'));
console.log(chalk.blue('copying profiles/ to build/...'));
fs.copy('profiles/', 'build/profiles', function (err) {
if (err) return console.error(err);
console.log(chalk.green('... done'));
console.log(chalk.blue('copying misc/ to build/...'));
fs.copy('misc/', 'build/misc', function (err) {
if (err) return console.error(err);
console.log(chalk.green('... done'));
console.log(chalk.blue('copying database/ to build/...'));
fs.copy('database/', 'build/database', function (err) {
if (err) return console.error(err);
console.log(chalk.green('... done'));
console.log(chalk.green('all done copying!'));
console.log(chalk.blue('replacing icon...'));
// This doesn't seem to work yet
const { exec } = require('child_process');
exec(
'start dev/ResourceHacker.exe -addoverwrite "build/Server.exe", "build/Server.exe", "iconset.ico", ICONGROUP, MAINICON, 0',
(error, stdout, stderr) => {
if (error) {
console.log(chalk.red(`error: ${error.message}`));
return;
}
if (stderr) {
console.log(chalk.red(`stderr: ${stderr}`));
return;
}
console.log(chalk.blue(`stdout: ${stdout}`));
console.log(chalk.green('... done'));
console.log(chalk.green('==> build finished!'));
},
);
});
});
});
});
})();