From d443f81f4e04b47780f3c0e6343423c07b5184bc Mon Sep 17 00:00:00 2001 From: Caelan Sayler Date: Sun, 20 Oct 2024 14:50:05 +0100 Subject: [PATCH] Fix nodejs tests --- src/lib-nodejs/package.json | 2 +- src/lib-nodejs/src/load.ts | 14 ++++---------- src/lib-nodejs/test/helper.ts | 28 +++++++++++++++++----------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lib-nodejs/package.json b/src/lib-nodejs/package.json index 3ad42648..dbfa091c 100644 --- a/src/lib-nodejs/package.json +++ b/src/lib-nodejs/package.json @@ -6,7 +6,7 @@ "types": "./lib/index.d.ts", "scripts": { "test": "npm run dev && cross-env VELOPACK_RESTART=true VELOPACK_DEBUG=true jest", - "dev": "cargo build -p velopack_nodeffi && tsc -p tsconfig.build.json && node copy-lib.js", + "dev": "cargo build -p velopack_nodeffi -p velopack_bins && tsc -p tsconfig.build.json && node copy-lib.js", "build": "tsc -p tsconfig.build.json", "clean": "del-cli **/*.node lib velopack-*.tgz", "lint": "prettier . --write" diff --git a/src/lib-nodejs/src/load.ts b/src/lib-nodejs/src/load.ts index 2873ca47..a6f0ae7a 100644 --- a/src/lib-nodejs/src/load.ts +++ b/src/lib-nodejs/src/load.ts @@ -2,17 +2,11 @@ import { proxy } from "@neon-rs/load"; module.exports = proxy({ platforms: { - "win32-x86-msvc": () => - require("./native/velopack_nodeffi_win_x86_msvc.node"), - "win32-x64-msvc": () => - require("./native/velopack_nodeffi_win_x64_msvc.node"), - "win32-arm64-msvc": () => - require("./native/velopack_nodeffi_win_arm64_msvc.node"), + "win32-x64-msvc": () => require("./native/velopack_nodeffi_win_x64_msvc.node"), + "win32-arm64-msvc": () => require("./native/velopack_nodeffi_win_arm64_msvc.node"), "darwin-x64": () => require("./native/velopack_nodeffi_osx.node"), "darwin-arm64": () => require("./native/velopack_nodeffi_osx.node"), - "linux-x64-gnu": () => - require("./native/velopack_nodeffi_linux_x64_gnu.node"), - "linux-arm64-gnu": () => - require("./native/velopack_nodeffi_linux_arm64_gnu.node"), + "linux-x64-gnu": () => require("./native/velopack_nodeffi_linux_x64_gnu.node"), + "linux-arm64-gnu": () => require("./native/velopack_nodeffi_linux_arm64_gnu.node"), }, }); diff --git a/src/lib-nodejs/test/helper.ts b/src/lib-nodejs/test/helper.ts index aa1e86ab..9a35d525 100644 --- a/src/lib-nodejs/test/helper.ts +++ b/src/lib-nodejs/test/helper.ts @@ -116,27 +116,29 @@ export async function tempd3( export function updateExe(): string { const paths = []; + const debugDir = path.join("..", "..", "target", "debug"); + const releaseDir = path.join("..", "..", "target", "release"); if (isMacos()) { - paths.push(path.join("..", "..", "target", "release", "UpdateMac")); + paths.push(path.join(releaseDir, "UpdateMac")); } if (isLinux()) { if (os.machine() == "x86_64") { - paths.push(path.join("..", "..", "target", "release", "UpdateNix_x64")); + paths.push(path.join(releaseDir, "UpdateNix_x64")); } else if (os.machine() == "aarch64" || os.machine() == "arm64") { - paths.push(path.join("..", "..", "target", "release", "UpdateNix_arm64")); + paths.push(path.join(releaseDir, "UpdateNix_arm64")); } } if (isMacos() || isLinux()) { - paths.push(path.join("..", "..", "target", "debug", "update")); - paths.push(path.join("..", "..", "target", "release", "update")); + paths.push(path.join(debugDir, "update")); + paths.push(path.join(releaseDir, "update")); } if (isWindows()) { - paths.push(path.join("..", "..", "target", "debug", "Update.exe")); - paths.push(path.join("..", "..", "target", "release", "Update.exe")); + paths.push(path.join(debugDir, "Update.exe")); + paths.push(path.join(releaseDir, "Update.exe")); } for (const p of paths) { @@ -151,12 +153,16 @@ export function updateExe(): string { paths.join(", ") + ". And found these binaries: "; - for (const file of fs.readdirSync(path.join("..", "..", "target", "debug"))) { - message += file + ", "; + if (fs.existsSync(debugDir)) { + for (const file of fs.readdirSync(debugDir)) { + message += file + ", "; + } } - for (const file of fs.readdirSync(path.join("..", "..", "target", "release"))) { - message += file + ", "; + if (fs.existsSync(releaseDir)) { + for (const file of fs.readdirSync(releaseDir)) { + message += file + ", "; + } } throw new Error(message);