mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Fix nodejs tests
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* VelopackLocator provides some utility functions for locating the current app important paths (eg. path to packages, update binary, and so forth).
|
||||
*/
|
||||
export type VelopackPaths = {
|
||||
/**
|
||||
* The root directory of the current app.
|
||||
*/
|
||||
RootAppDir: string,
|
||||
/**
|
||||
* The path to the Update.exe binary.
|
||||
*/
|
||||
UpdateExePath: string,
|
||||
/**
|
||||
* The path to the packages directory.
|
||||
*/
|
||||
PackagesDir: string,
|
||||
/**
|
||||
* The current app manifest.
|
||||
*/
|
||||
ManifestPath: string,
|
||||
/**
|
||||
* The directory containing the application's user binaries
|
||||
*/
|
||||
CurrentBinaryDir: string, };
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as addon from "./load";
|
||||
import type { UpdateInfo } from "./bindings/UpdateInfo";
|
||||
import type { UpdateOptions } from "./bindings/UpdateOptions";
|
||||
import type { VelopackLocator } from "./bindings/VelopackLocator";
|
||||
import type { VelopackLocatorConfig } from "./bindings/VelopackLocatorConfig";
|
||||
|
||||
export { UpdateInfo, UpdateOptions, VelopackLocator };
|
||||
export { UpdateInfo, UpdateOptions, VelopackLocatorConfig };
|
||||
|
||||
type UpdateManagerOpaque = {};
|
||||
declare module "./load" {
|
||||
@@ -64,7 +64,7 @@ type LogLevel = "info" | "warn" | "error" | "debug" | "trace";
|
||||
export class VelopackApp {
|
||||
private _hooks = new Map<VelopackHookType, VelopackHook>();
|
||||
private _customArgs: string[] | null = null;
|
||||
private _customLocator: VelopackLocator | null = null;
|
||||
private _customLocator: VelopackLocatorConfig | null = null;
|
||||
|
||||
static build(): VelopackApp {
|
||||
return new VelopackApp();
|
||||
@@ -141,7 +141,7 @@ export class VelopackApp {
|
||||
/**
|
||||
* VelopackLocator provides some utility functions for locating the current app important paths (eg. path to packages, update binary, and so forth).
|
||||
*/
|
||||
setLocator(locator: VelopackLocator): VelopackApp {
|
||||
setLocator(locator: VelopackLocatorConfig): VelopackApp {
|
||||
this._customLocator = locator;
|
||||
return this;
|
||||
}
|
||||
@@ -173,12 +173,12 @@ export class VelopackApp {
|
||||
}
|
||||
|
||||
export class UpdateManager {
|
||||
private opaque: UpdateManagerOpaque;
|
||||
private readonly opaque: UpdateManagerOpaque;
|
||||
|
||||
constructor(
|
||||
urlOrPath: string,
|
||||
options?: UpdateOptions,
|
||||
locator?: VelopackLocator,
|
||||
locator?: VelopackLocatorConfig,
|
||||
) {
|
||||
this.opaque = addon.js_new_update_manager(
|
||||
urlOrPath,
|
||||
|
||||
@@ -3,24 +3,25 @@ import {
|
||||
UpdateManager,
|
||||
UpdateOptions,
|
||||
VelopackApp,
|
||||
VelopackLocator,
|
||||
VelopackLocatorConfig,
|
||||
} from "../src";
|
||||
import path from "path";
|
||||
import { tempd4, fixture, updateExe, shortDelay } from "./helper";
|
||||
import { tempd3, fixture, updateExe, shortDelay } from "./helper";
|
||||
|
||||
test("UpdateManager detects local update", () => {
|
||||
return tempd4(async (tmpDir, packagesDir, rootDir, appTemp) => {
|
||||
return tempd3(async (tmpDir, packagesDir, rootDir) => {
|
||||
VelopackApp.build()
|
||||
.setLogger((level, msg) => {
|
||||
console.log(level, msg);
|
||||
})
|
||||
.run();
|
||||
const locator: VelopackLocator = {
|
||||
const locator: VelopackLocatorConfig = {
|
||||
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
|
||||
PackagesDir: packagesDir,
|
||||
RootAppDir: rootDir,
|
||||
UpdateExePath: updateExe(),
|
||||
TempDir: appTemp,
|
||||
CurrentBinaryDir: path.join(rootDir, "current"),
|
||||
IsPortable: true,
|
||||
};
|
||||
|
||||
const options: UpdateOptions = {
|
||||
@@ -46,18 +47,19 @@ test("UpdateManager detects local update", () => {
|
||||
});
|
||||
|
||||
test("UpdateManager downloads full update", () => {
|
||||
return tempd4(async (feedDir, packagesDir, rootDir, appTemp) => {
|
||||
return tempd3(async (feedDir, packagesDir, rootDir) => {
|
||||
VelopackApp.build()
|
||||
.setLogger((level, msg) => {
|
||||
console.log(level, msg);
|
||||
})
|
||||
.run();
|
||||
const locator: VelopackLocator = {
|
||||
const locator: VelopackLocatorConfig = {
|
||||
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
|
||||
PackagesDir: packagesDir,
|
||||
RootAppDir: rootDir,
|
||||
UpdateExePath: updateExe(),
|
||||
TempDir: appTemp,
|
||||
CurrentBinaryDir: path.join(rootDir, "current"),
|
||||
IsPortable: true,
|
||||
};
|
||||
|
||||
const options: UpdateOptions = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { VelopackApp, VelopackLocator } from "../src/index";
|
||||
import { VelopackApp, VelopackLocatorConfig } from "../src/index";
|
||||
import { shortDelay } from "./helper";
|
||||
|
||||
class HookTester {
|
||||
@@ -46,12 +46,13 @@ class HookTester {
|
||||
|
||||
test("VelopackApp should handle restarted event", async () => {
|
||||
let [builder, tester] = HookTester.build();
|
||||
let locator: VelopackLocator = {
|
||||
let locator: VelopackLocatorConfig = {
|
||||
ManifestPath: "../../test/fixtures/Test.Squirrel-App.nuspec",
|
||||
PackagesDir: "",
|
||||
RootAppDir: "",
|
||||
UpdateExePath: "",
|
||||
TempDir: "",
|
||||
CurrentBinaryDir: "",
|
||||
IsPortable: true,
|
||||
};
|
||||
builder.setLocator(locator).run();
|
||||
|
||||
|
||||
@@ -47,26 +47,26 @@ export function makeId(length: number): string {
|
||||
// }
|
||||
// }
|
||||
|
||||
// export async function tempd3<T>(
|
||||
// cb: (dir1: string, dir2: string, dir3: string) => 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 });
|
||||
// }
|
||||
// }
|
||||
export async function tempd3<T>(
|
||||
cb: (dir1: string, dir2: string, dir3: string) => 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 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function tempd4<T>(
|
||||
cb: (dir1: string, dir2: string, dir3: string, dir4: string) => T,
|
||||
cb: (dir1: string, dir2: string, dir3: string, dir4: string) => T,
|
||||
): Promise<T> {
|
||||
const dir1 = path.join(os.tmpdir(), makeId(16));
|
||||
const dir2 = path.join(os.tmpdir(), makeId(16));
|
||||
|
||||
Reference in New Issue
Block a user