Quick fix for built PKG CLI version, make sure prebuilds are loaded correctly.
This commit is contained in:
parent
c7c81c348b
commit
0912720f19
|
@ -12,6 +12,10 @@ if (!process.argv[0].includes("node")) {
|
||||||
checkForBinaries()
|
checkForBinaries()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function localPrebuildPath() {
|
||||||
|
return join(process.execPath, "..", PREBUILDS)
|
||||||
|
}
|
||||||
|
|
||||||
function checkForBinaries() {
|
function checkForBinaries() {
|
||||||
const readDir = join(__filename, "..", "..", "..", "cli", PREBUILDS, ARCH)
|
const readDir = join(__filename, "..", "..", "..", "cli", PREBUILDS, ARCH)
|
||||||
if (fs.existsSync(PREBUILD_DIR) || !fs.existsSync(readDir)) {
|
if (fs.existsSync(PREBUILD_DIR) || !fs.existsSync(readDir)) {
|
||||||
|
@ -19,17 +23,21 @@ function checkForBinaries() {
|
||||||
}
|
}
|
||||||
const natives = fs.readdirSync(readDir)
|
const natives = fs.readdirSync(readDir)
|
||||||
if (fs.existsSync(readDir)) {
|
if (fs.existsSync(readDir)) {
|
||||||
const writePath = join(process.execPath, PREBUILDS, ARCH)
|
const writePath = join(localPrebuildPath(), ARCH)
|
||||||
fs.mkdirSync(writePath, { recursive: true })
|
fs.mkdirSync(writePath, { recursive: true })
|
||||||
for (let native of natives) {
|
for (let native of natives) {
|
||||||
const filename = `${native.split(".fake")[0]}.node`
|
const filename = `${native.split(".fake")[0]}.node`
|
||||||
fs.cpSync(join(readDir, native), join(writePath, filename))
|
fs.cpSync(join(readDir, native), join(writePath, filename))
|
||||||
}
|
}
|
||||||
console.log("copied something")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup(evt?: number) {
|
function cleanup(evt?: number) {
|
||||||
|
// cleanup prebuilds first
|
||||||
|
const path = localPrebuildPath()
|
||||||
|
if (fs.existsSync(path)) {
|
||||||
|
fs.rmSync(path, { recursive: true })
|
||||||
|
}
|
||||||
if (evt && !isNaN(evt)) {
|
if (evt && !isNaN(evt)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -41,10 +49,6 @@ function cleanup(evt?: number) {
|
||||||
)
|
)
|
||||||
console.error(error(evt))
|
console.error(error(evt))
|
||||||
}
|
}
|
||||||
const path = join(process.execPath, PREBUILDS)
|
|
||||||
if (fs.existsSync(path)) {
|
|
||||||
fs.rmSync(path, { recursive: true })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException"]
|
const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException"]
|
||||||
|
|
Loading…
Reference in New Issue