setup-cpp/dev/scripts/pack-exe.ts

46 lines
849 B
TypeScript
Raw Normal View History

2022-11-09 08:08:38 +08:00
/* eslint-disable import/no-extraneous-dependencies */
import { node } from "execa"
2021-09-15 14:29:57 +08:00
function getPlatformName() {
switch (process.platform) {
case "win32": {
return "windows"
}
case "darwin": {
return "mac"
}
default: {
return process.platform
}
}
}
function main() {
let exes
if (process.platform === "win32") {
exes = [".exe"]
} else if (process.platform === "darwin") {
exes = [""]
2021-09-15 14:29:57 +08:00
} else {
exes = [""]
2021-09-15 14:29:57 +08:00
}
return Promise.all(
exes.map((exe) =>
node("./node_modules/caxa/build/index.mjs", [
"--input",
"./dist/node16",
"--output",
`./exe/setup_cpp_${getPlatformName()}${exe}`,
"--",
`{{caxa}}/node_modules/.bin/node${exe}`,
`{{caxa}}/setup_cpp.js`,
])
2021-09-15 14:29:57 +08:00
)
)
}
main().catch((err) => {
throw err
2021-09-15 14:29:57 +08:00
})