1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00

Fixing pkg built CLI after using esbuild.

This commit is contained in:
mike12345567 2023-08-07 20:21:36 +01:00
parent 4d0c7e56e1
commit cb1cec2774
2 changed files with 12 additions and 10 deletions

View file

@ -19,12 +19,11 @@
},
"pkg": {
"targets": [
"node16-linux",
"node16-win",
"node16-macos"
"node18-linux",
"node18-win",
"node18-macos"
],
"assets": [
"node_modules/@budibase/backend-core/dist/**/*",
"prebuilds/**/*"
],
"outputPath": "build"

View file

@ -5,7 +5,7 @@ import { error } from "./utils"
const PREBUILDS = "prebuilds"
const ARCH = `${os.platform()}-${os.arch()}`
const PREBUILD_DIR = join(process.execPath, "..", PREBUILDS, ARCH)
const PREBUILD_DIR = join(process.execPath, "..", "cli", PREBUILDS, ARCH)
// running as built CLI pkg bundle
if (!process.argv[0].includes("node")) {
@ -13,17 +13,19 @@ if (!process.argv[0].includes("node")) {
}
function checkForBinaries() {
const readDir = join(__filename, "..", "..", "..", PREBUILDS, ARCH)
const readDir = join(__filename, "..", "..", "..", "cli", PREBUILDS, ARCH)
if (fs.existsSync(PREBUILD_DIR) || !fs.existsSync(readDir)) {
return
}
const natives = fs.readdirSync(readDir)
if (fs.existsSync(readDir)) {
fs.mkdirSync(PREBUILD_DIR, { recursive: true })
const writePath = join(process.execPath, PREBUILDS, ARCH)
fs.mkdirSync(writePath, { recursive: true })
for (let native of natives) {
const filename = `${native.split(".fake")[0]}.node`
fs.cpSync(join(readDir, native), join(PREBUILD_DIR, filename))
fs.cpSync(join(readDir, native), join(writePath, filename))
}
console.log("copied something")
}
}
@ -39,8 +41,9 @@ function cleanup(evt?: number) {
)
console.error(error(evt))
}
if (fs.existsSync(PREBUILD_DIR)) {
fs.rmSync(PREBUILD_DIR, { recursive: true })
const path = join(process.execPath, PREBUILDS)
if (fs.existsSync(path)) {
fs.rmSync(path, { recursive: true })
}
}