test: made tests work in windows

This commit is contained in:
Simeon Radivoev 2026-03-31 04:44:42 +03:00
parent 8a0be8c913
commit 4271f268c3
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
9 changed files with 57 additions and 20 deletions

View file

@ -11,6 +11,7 @@ import fs from "node:fs/promises";
import { Downloader } from "@/bun/utils/downloader";
import { ensureDir, move } from "fs-extra";
import { simulateProgress } from "@/bun/utils";
import { path7za } from "7zip-bin";
type EmulatorDownloadStates = "download" | "extract";
@ -97,7 +98,7 @@ export class EmulatorDownloadJob implements IJob<z.infer<typeof EmulatorDownload
let destinationPath = destinationPaths[0];
await new Promise((resolve, reject) =>
{
const seven = Seven.extractFull(destinationPath, emulatorsFolder, { $bin: process.env.ZIP7_PATH, $progress: true });
const seven = Seven.extractFull(destinationPath, emulatorsFolder, { $bin: process.env.ZIP7_PATH ?? path7za, $progress: true, noRootDuplication: true });
seven.on('progress', p => context.setProgress(p.percent, "extract"));
seven.on('error', e => reject(e));
seven.on('end', () => resolve(true));

View file

@ -14,6 +14,7 @@ import Seven from 'node-7z';
import z from "zod";
import { checkFiles } from "../games/services/utils";
import { ensureDir } from "fs-extra";
import { path7za } from "7zip-bin";
interface JobConfig
{
@ -45,7 +46,7 @@ export class InstallJob implements IJob<never, InstallJobStates>
public async start (cx: JobContext<InstallJob, never, InstallJobStates>)
{
cx.setProgress(0, 'download');
fs.mkdir(config.get('downloadPath'), { recursive: true });
await fs.mkdir(config.get('downloadPath'), { recursive: true });
const downloadPath = config.get('downloadPath');
let info: DownloadInfo | undefined;
@ -111,7 +112,7 @@ export class InstallJob implements IJob<never, InstallJobStates>
const extractPath = path.join(config.get('downloadPath'), info.extract_path);
await new Promise((resolve, reject) =>
{
const seven = Seven.extractFull(filePath, extractPath, { $bin: process.env.ZIP7_PATH, $progress: true });
const seven = Seven.extractFull(filePath, extractPath, { $bin: process.env.ZIP7_PATH ?? path7za, $progress: true });
seven.on('progress', p =>
{
cx.setProgress(progress + p.percent * progressDelta, "extract");