-
Notifications
You must be signed in to change notification settings - Fork 31
/
build.cjs
58 lines (52 loc) · 1.14 KB
/
build.cjs
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
const path = require("path");
const { exec } = require("pkg");
const webpack = require("webpack");
const { version } = require("./package.json");
const targetMap = [
{
target: "node18-linux-x64",
output: `./binaries/podcast-dl-${version}-linux-x64`,
},
{
target: "node18-macos-x64",
output: `./binaries/podcast-dl-${version}-macos-x64`,
},
{
target: "node18-win-x64",
output: `./binaries/podcast-dl-${version}-win-x64`,
},
];
const buildBinaries = async () => {
for (const targetMapping of targetMap) {
await exec([
`./dist/podcast-dl-${version}.js`,
"--target",
targetMapping.target,
"--output",
targetMapping.output,
]);
}
};
const main = async () => {
webpack(
{
mode: "production",
target: "node",
entry: {
main: path.resolve(__dirname, "./bin/bin.js"),
},
output: {
path: path.resolve(__dirname, "./dist"),
filename: `podcast-dl-${version}.js`,
},
},
async (error) => {
if (error) {
console.error(error);
process.exit(1);
}
await buildBinaries();
}
);
};
main();