This commit is contained in:
Caelan
2024-10-07 11:47:12 -06:00
parent e55a11ab3a
commit 425885f7a9
6 changed files with 292 additions and 281 deletions

View File

@@ -5,31 +5,31 @@ const path = require("node:path");
const platform = os.platform();
function makeCopies(input) {
// this is obviously not correct for a "production" bundle, but it is used for testing
// creating a "node" module at all of the expected production locations allows us to test
// webpack require resolution and native module bundling etc.
if (!fs.existsSync("./lib/native")) fs.mkdirSync("./lib/native");
if (!fs.existsSync("./src/native")) fs.mkdirSync("./src/native");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_win_x86_msvc.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_win_x64_msvc.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_win_arm64_msvc.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_osx.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_linux_x64_gnu.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_linux_arm64_gnu.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_win_x86_msvc.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_win_x64_msvc.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_win_arm64_msvc.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_osx.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_linux_x64_gnu.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_linux_arm64_gnu.node");
// this is obviously not correct for a "production" bundle, but it is used for testing
// creating a "node" module at all of the expected production locations allows us to test
// webpack require resolution and native module bundling etc.
if (!fs.existsSync("./lib/native")) fs.mkdirSync("./lib/native");
if (!fs.existsSync("./src/native")) fs.mkdirSync("./src/native");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_win_x86_msvc.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_win_x64_msvc.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_win_arm64_msvc.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_osx.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_linux_x64_gnu.node");
fs.copyFileSync(input, "./lib/native/velopack_nodeffi_linux_arm64_gnu.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_win_x86_msvc.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_win_x64_msvc.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_win_arm64_msvc.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_osx.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_linux_x64_gnu.node");
fs.copyFileSync(input, "./src/native/velopack_nodeffi_linux_arm64_gnu.node");
}
if (platform == "win32") {
makeCopies("../../target/debug/velopack_nodeffi.dll");
makeCopies("../../target/debug/velopack_nodeffi.dll");
} else if (platform == "darwin") {
makeCopies("../../target/debug/libvelopack_nodeffi.dylib");
makeCopies("../../target/debug/libvelopack_nodeffi.dylib");
} else if (platform == "linux") {
makeCopies("../../target/debug/libvelopack_nodeffi.so");
makeCopies("../../target/debug/libvelopack_nodeffi.so");
} else {
throw new Error("Unsupported platform: " + platform);
throw new Error("Unsupported platform: " + platform);
}

View File

@@ -16,10 +16,12 @@ declare module "./load" {
function js_get_current_version(um: UpdateManagerOpaque): string;
function js_get_app_id(um: UpdateManagerOpaque): string;
function js_is_portable(um: UpdateManagerOpaque): boolean;
function js_update_pending_restart(um: UpdateManagerOpaque): UpdateInfo | null;
function js_update_pending_restart(
um: UpdateManagerOpaque,
): UpdateInfo | null;
function js_check_for_updates_async(
um: UpdateManagerOpaque,
@@ -156,7 +158,6 @@ export class VelopackApp {
this._autoApply = autoApply;
return this;
}
/**
* Runs the Velopack startup logic. This should be the first thing to run in your app.
@@ -172,7 +173,7 @@ export class VelopackApp {
},
this._customArgs,
this._customLocator ? JSON.stringify(this._customLocator) : null,
this._autoApply
this._autoApply,
);
}
}
@@ -207,7 +208,7 @@ export class UpdateManager {
}
/**
* Returns whether the app is in portable mode. On Windows this can be true or false.
* Returns whether the app is in portable mode. On Windows this can be true or false.
* On MacOS and Linux this will always be true.
*/
isPortable(): boolean {
@@ -287,6 +288,8 @@ export class UpdateManager {
/**
* Set a custom logger callback to receive log messages from Velopack. The default behavior is to log to console.log.
*/
export function setVelopackLogger(callback: (loglevel: LogLevel, msg: string) => void) {
export function setVelopackLogger(
callback: (loglevel: LogLevel, msg: string) => void,
) {
addon.js_set_logger_callback(callback);
}
}

View File

@@ -2,12 +2,17 @@ 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-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"),
"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"),
},
});

View File

@@ -1,87 +1,88 @@
import {copyFileSync, existsSync} from "fs";
import { copyFileSync, existsSync } from "fs";
import {
UpdateManager,
UpdateOptions,
VelopackApp,
VelopackLocatorConfig,
setVelopackLogger,
UpdateManager,
UpdateOptions,
VelopackApp,
VelopackLocatorConfig,
setVelopackLogger,
} from "../src";
import path from "path";
import {tempd3, fixture, updateExe, captureLogs} from "./helper";
import { tempd3, fixture, updateExe, captureLogs } from "./helper";
test("UpdateManager detects local update", async () => {
await captureLogs(async () => {
await tempd3(async (tmpDir, packagesDir, rootDir) => {
const locator: VelopackLocatorConfig = {
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
PackagesDir: packagesDir,
RootAppDir: rootDir,
UpdateExePath: updateExe(),
CurrentBinaryDir: path.join(rootDir, "current"),
IsPortable: true,
};
await captureLogs(async () => {
await tempd3(async (tmpDir, packagesDir, rootDir) => {
const locator: VelopackLocatorConfig = {
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
PackagesDir: packagesDir,
RootAppDir: rootDir,
UpdateExePath: updateExe(),
CurrentBinaryDir: path.join(rootDir, "current"),
IsPortable: true,
};
const options: UpdateOptions = {
ExplicitChannel: "beta",
AllowVersionDowngrade: false,
};
const options: UpdateOptions = {
ExplicitChannel: "beta",
AllowVersionDowngrade: false,
};
const um = new UpdateManager(tmpDir, options, locator);
copyFileSync(
fixture("testfeed.json"),
path.join(tmpDir, "releases.beta.json"),
);
const update = await um.checkForUpdatesAsync();
const um = new UpdateManager(tmpDir, options, locator);
copyFileSync(
fixture("testfeed.json"),
path.join(tmpDir, "releases.beta.json"),
);
const update = await um.checkForUpdatesAsync();
expect(update).not.toBeNull();
expect(update?.TargetFullRelease).not.toBeNull();
expect(update?.TargetFullRelease?.Version).toBe("1.0.11");
expect(update?.TargetFullRelease?.FileName).toBe(
"AvaloniaCrossPlat-1.0.11-full.nupkg",
);
});
expect(update).not.toBeNull();
expect(update?.TargetFullRelease).not.toBeNull();
expect(update?.TargetFullRelease?.Version).toBe("1.0.11");
expect(update?.TargetFullRelease?.FileName).toBe(
"AvaloniaCrossPlat-1.0.11-full.nupkg",
);
});
});
});
test("UpdateManager downloads full update", async () => {
await captureLogs(async () => {
await tempd3(async (feedDir, packagesDir, rootDir) => {
const locator: VelopackLocatorConfig = {
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
PackagesDir: packagesDir,
RootAppDir: rootDir,
UpdateExePath: updateExe(),
CurrentBinaryDir: path.join(rootDir, "current"),
IsPortable: true,
};
await captureLogs(async () => {
await tempd3(async (feedDir, packagesDir, rootDir) => {
const locator: VelopackLocatorConfig = {
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
PackagesDir: packagesDir,
RootAppDir: rootDir,
UpdateExePath: updateExe(),
CurrentBinaryDir: path.join(rootDir, "current"),
IsPortable: true,
};
const options: UpdateOptions = {
ExplicitChannel: "beta",
AllowVersionDowngrade: false,
};
const options: UpdateOptions = {
ExplicitChannel: "beta",
AllowVersionDowngrade: false,
};
const um = new UpdateManager(feedDir, options, locator);
copyFileSync(
fixture("testfeed.json"),
path.join(feedDir, "releases.beta.json"),
);
const um = new UpdateManager(feedDir, options, locator);
copyFileSync(
fixture("testfeed.json"),
path.join(feedDir, "releases.beta.json"),
);
copyFileSync(
fixture("AvaloniaCrossPlat-1.0.11-win-full.nupkg"),
path.join(feedDir, "AvaloniaCrossPlat-1.0.11-full.nupkg"),
);
copyFileSync(
fixture("AvaloniaCrossPlat-1.0.11-win-full.nupkg"),
path.join(feedDir, "AvaloniaCrossPlat-1.0.11-full.nupkg"),
);
const update = await um.checkForUpdatesAsync();
const update = await um.checkForUpdatesAsync();
console.log(
`about to download update from ${feedDir} to ${packagesDir} ...`,
);
await um.downloadUpdateAsync(update!, () => {
});
console.log(
`about to download update from ${feedDir} to ${packagesDir} ...`,
);
await um.downloadUpdateAsync(update!, () => {});
expect(
existsSync(path.join(packagesDir, "AvaloniaCrossPlat-1.0.11-full.nupkg")),
).toBe(true);
});
expect(
existsSync(
path.join(packagesDir, "AvaloniaCrossPlat-1.0.11-full.nupkg"),
),
).toBe(true);
});
});
});

View File

@@ -1,129 +1,129 @@
import {VelopackApp, VelopackLocatorConfig, setVelopackLogger} from "../src";
import {isWindows, captureLogs} from "./helper";
import { VelopackApp, VelopackLocatorConfig, setVelopackLogger } from "../src";
import { isWindows, captureLogs } from "./helper";
class HookTester {
public afterInstall = false;
public beforeUninstall = false;
public beforeUpdate = false;
public afterUpdate = false;
public restarted = false;
public firstRun = false;
public version = "";
public afterInstall = false;
public beforeUninstall = false;
public beforeUpdate = false;
public afterUpdate = false;
public restarted = false;
public firstRun = false;
public version = "";
static build(): [VelopackApp, HookTester] {
let tester = new HookTester();
let builder = VelopackApp.build();
builder.onAfterInstallFastCallback((ver) => {
tester.afterInstall = true;
tester.version = ver;
});
builder.onBeforeUninstallFastCallback((ver) => {
tester.beforeUninstall = true;
tester.version = ver;
});
builder.onBeforeUpdateFastCallback((ver) => {
tester.beforeUpdate = true;
tester.version = ver;
});
builder.onAfterUpdateFastCallback((ver) => {
tester.afterUpdate = true;
tester.version = ver;
});
builder.onRestarted((ver) => {
tester.restarted = true;
tester.version = ver;
});
builder.onFirstRun((ver) => {
tester.firstRun = true;
tester.version = ver;
});
return [builder, tester];
}
static build(): [VelopackApp, HookTester] {
let tester = new HookTester();
let builder = VelopackApp.build();
builder.onAfterInstallFastCallback((ver) => {
tester.afterInstall = true;
tester.version = ver;
});
builder.onBeforeUninstallFastCallback((ver) => {
tester.beforeUninstall = true;
tester.version = ver;
});
builder.onBeforeUpdateFastCallback((ver) => {
tester.beforeUpdate = true;
tester.version = ver;
});
builder.onAfterUpdateFastCallback((ver) => {
tester.afterUpdate = true;
tester.version = ver;
});
builder.onRestarted((ver) => {
tester.restarted = true;
tester.version = ver;
});
builder.onFirstRun((ver) => {
tester.firstRun = true;
tester.version = ver;
});
return [builder, tester];
}
}
test("VelopackApp should handle restarted event", async () => {
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
let locator: VelopackLocatorConfig = {
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
PackagesDir: "",
RootAppDir: "",
UpdateExePath: "",
CurrentBinaryDir: "",
IsPortable: true,
};
builder.setLocator(locator).run();
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
let locator: VelopackLocatorConfig = {
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
PackagesDir: "",
RootAppDir: "",
UpdateExePath: "",
CurrentBinaryDir: "",
IsPortable: true,
};
builder.setLocator(locator).run();
expect(tester.afterInstall).toBe(false);
expect(tester.beforeUninstall).toBe(false);
expect(tester.beforeUpdate).toBe(false);
expect(tester.afterUpdate).toBe(false);
expect(tester.restarted).toBe(true);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.0.0");
});
expect(tester.afterInstall).toBe(false);
expect(tester.beforeUninstall).toBe(false);
expect(tester.beforeUpdate).toBe(false);
expect(tester.afterUpdate).toBe(false);
expect(tester.restarted).toBe(true);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.0.0");
});
});
test("VelopackApp should handle after-install hook", async () => {
if (!isWindows()) return;
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
builder.setArgs(["--veloapp-install", "1.2.3-test.4"]).run();
if (!isWindows()) return;
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
builder.setArgs(["--veloapp-install", "1.2.3-test.4"]).run();
expect(tester.afterInstall).toBe(true);
expect(tester.beforeUninstall).toBe(false);
expect(tester.beforeUpdate).toBe(false);
expect(tester.afterUpdate).toBe(false);
expect(tester.restarted).toBe(false);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.2.3-test.4");
});
expect(tester.afterInstall).toBe(true);
expect(tester.beforeUninstall).toBe(false);
expect(tester.beforeUpdate).toBe(false);
expect(tester.afterUpdate).toBe(false);
expect(tester.restarted).toBe(false);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.2.3-test.4");
});
});
test("VelopackApp should handle before-uninstall hook", async () => {
if (!isWindows()) return;
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
builder.setArgs(["--veloapp-uninstall", "1.2.3-test"]).run();
if (!isWindows()) return;
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
builder.setArgs(["--veloapp-uninstall", "1.2.3-test"]).run();
expect(tester.afterInstall).toBe(false);
expect(tester.beforeUninstall).toBe(true);
expect(tester.beforeUpdate).toBe(false);
expect(tester.afterUpdate).toBe(false);
expect(tester.restarted).toBe(false);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.2.3-test");
});
expect(tester.afterInstall).toBe(false);
expect(tester.beforeUninstall).toBe(true);
expect(tester.beforeUpdate).toBe(false);
expect(tester.afterUpdate).toBe(false);
expect(tester.restarted).toBe(false);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.2.3-test");
});
});
test("VelopackApp should handle after-update hook", async () => {
if (!isWindows()) return;
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
builder.setArgs(["--veloapp-updated", "1.2.3"]).run();
if (!isWindows()) return;
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
builder.setArgs(["--veloapp-updated", "1.2.3"]).run();
expect(tester.afterInstall).toBe(false);
expect(tester.beforeUninstall).toBe(false);
expect(tester.beforeUpdate).toBe(false);
expect(tester.afterUpdate).toBe(true);
expect(tester.restarted).toBe(false);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.2.3");
});
expect(tester.afterInstall).toBe(false);
expect(tester.beforeUninstall).toBe(false);
expect(tester.beforeUpdate).toBe(false);
expect(tester.afterUpdate).toBe(true);
expect(tester.restarted).toBe(false);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.2.3");
});
});
test("VelopackApp should handle before-update hook", async () => {
if (!isWindows()) return;
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
builder.setArgs(["--veloapp-obsolete", "1.2.3-test.4"]).run();
if (!isWindows()) return;
await captureLogs(async () => {
let [builder, tester] = HookTester.build();
builder.setArgs(["--veloapp-obsolete", "1.2.3-test.4"]).run();
expect(tester.afterInstall).toBe(false);
expect(tester.beforeUninstall).toBe(false);
expect(tester.beforeUpdate).toBe(true);
expect(tester.afterUpdate).toBe(false);
expect(tester.restarted).toBe(false);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.2.3-test.4");
});
expect(tester.afterInstall).toBe(false);
expect(tester.beforeUninstall).toBe(false);
expect(tester.beforeUpdate).toBe(true);
expect(tester.afterUpdate).toBe(false);
expect(tester.restarted).toBe(false);
expect(tester.firstRun).toBe(false);
expect(tester.version).toBe("1.2.3-test.4");
});
});

View File

@@ -1,54 +1,54 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import {setVelopackLogger} from "../lib";
import { setVelopackLogger } from "../lib";
export function isWindows(): boolean {
return os.platform() == "win32";
return os.platform() == "win32";
}
export function isLinux(): boolean {
return os.platform() == "linux";
return os.platform() == "linux";
}
export function isMacos(): boolean {
return os.platform() == "darwin";
return os.platform() == "darwin";
}
export function getTempDir(): string {
return fs.realpathSync(os.tmpdir());
return fs.realpathSync(os.tmpdir());
}
export function fixture(name: string): string {
return path.join("..", "..", "test", "fixtures", name);
return path.join("..", "..", "test", "fixtures", name);
}
export function makeId(length: number): string {
let result = "";
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
let result = "";
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
}
export async function captureLogs<T>(cb: () => Promise<T>): Promise<T> {
setVelopackLogger((level, msg) => {
console.log(level, msg);
});
setVelopackLogger((level, msg) => {
console.log(level, msg);
});
try {
return await cb();
} finally {
await shortDelay();
setVelopackLogger(() => {
// unhook logger from jest
});
}
try {
return await cb();
} finally {
await shortDelay();
setVelopackLogger(() => {
// unhook logger from jest
});
}
}
// export function tempd1<T>(cb: (dir: string) => T): T {
@@ -76,21 +76,21 @@ export async function captureLogs<T>(cb: () => Promise<T>): Promise<T> {
// }
export async function tempd3<T>(
cb: (dir1: string, dir2: string, dir3: string) => Promise<T>,
cb: (dir1: string, dir2: string, dir3: string) => Promise<T>,
): Promise<T> {
const dir1 = path.join(os.tmpdir(), makeId(16));
const dir2 = path.join(os.tmpdir(), makeId(16));
const dir3 = path.join(os.tmpdir(), makeId(16));
fs.mkdirSync(dir1);
fs.mkdirSync(dir2);
fs.mkdirSync(dir3);
try {
return await cb(dir1, dir2, dir3);
} finally {
fs.rmSync(dir1, {recursive: true});
fs.rmSync(dir2, {recursive: true});
fs.rmSync(dir3, {recursive: true});
}
const dir1 = path.join(os.tmpdir(), makeId(16));
const dir2 = path.join(os.tmpdir(), makeId(16));
const dir3 = path.join(os.tmpdir(), makeId(16));
fs.mkdirSync(dir1);
fs.mkdirSync(dir2);
fs.mkdirSync(dir3);
try {
return await cb(dir1, dir2, dir3);
} finally {
fs.rmSync(dir1, { recursive: true });
fs.rmSync(dir2, { recursive: true });
fs.rmSync(dir3, { recursive: true });
}
}
// export async function tempd4<T>(
@@ -115,51 +115,53 @@ export async function tempd3<T>(
// }
export function updateExe(): string {
const paths = [];
const paths = [];
if (isMacos()) {
paths.push(path.join("..", "..", "target", "release", "UpdateMac"));
}
if (isMacos()) {
paths.push(path.join("..", "..", "target", "release", "UpdateMac"));
}
if (isLinux()) {
if (os.machine() == "x64") {
paths.push(path.join("..", "..", "target", "release", "UpdateNix_x64"));
} else if (os.machine() == "aarch64" || os.machine() == "arm64") {
paths.push(path.join("..", "..", "target", "release", "UpdateNix_arm64"));
}
if (isLinux()) {
if (os.machine() == "x64") {
paths.push(path.join("..", "..", "target", "release", "UpdateNix_x64"));
} else if (os.machine() == "aarch64" || os.machine() == "arm64") {
paths.push(path.join("..", "..", "target", "release", "UpdateNix_arm64"));
}
}
if (isMacos() || isLinux()) {
paths.push(path.join("..", "..", "target", "debug", "update"));
paths.push(path.join("..", "..", "target", "release", "update"));
}
if (isMacos() || isLinux()) {
paths.push(path.join("..", "..", "target", "debug", "update"));
paths.push(path.join("..", "..", "target", "release", "update"));
}
if (isWindows()) {
paths.push(path.join("..", "..", "target", "debug", "Update.exe"));
paths.push(path.join("..", "..", "target", "release", "Update.exe"));
}
if (isWindows()) {
paths.push(path.join("..", "..", "target", "debug", "Update.exe"));
paths.push(path.join("..", "..", "target", "release", "Update.exe"));
}
for (const p of paths) {
if (fs.existsSync(p)) {
return p;
}
for (const p of paths) {
if (fs.existsSync(p)) {
return p;
}
// could not find update.exe
let message = "Could not find update binary. Searched these paths: "
+ paths.join(", ") + ". And found these binaries: ";
for (const p of paths) {
for (const file of fs.readdirSync(p)) {
message += file + ", ";
}
}
// could not find update.exe
let message =
"Could not find update binary. Searched these paths: " +
paths.join(", ") +
". And found these binaries: ";
for (const p of paths) {
for (const file of fs.readdirSync(p)) {
message += file + ", ";
}
throw new Error(message);
}
throw new Error(message);
}
function shortDelay(): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, 150));
return new Promise((resolve) => setTimeout(resolve, 150));
}
// export function copyUpdateExeTo(dir: string, filename?: string): string {