fix: copy unrar.wasm as part of the postinstallation process

This commit is contained in:
lilezek 2024-05-04 19:27:14 +02:00
parent 8b304dc46c
commit 8caea2893d
4 changed files with 12 additions and 2 deletions

View file

@ -1,12 +1,18 @@
import { Extractor, createExtractorFromFile } from "node-unrar-js";
import fs from "node:fs";
import path from "node:path";
import { app } from "electron";
const wasmPath = app.isPackaged
? path.join(process.resourcesPath, "unrar.wasm")
: path.join(__dirname, "..", "..", "unrar.wasm");
const wasmBinary = fs.readFileSync(
require.resolve("node-unrar-js/esm/js/unrar.wasm")
require.resolve(wasmPath)
);
export class Unrar {
private constructor(private extractor: Extractor<Uint8Array>) {}
private constructor(private extractor: Extractor<Uint8Array>) { }
static async fromFilePath(filePath: string, targetFolder: string) {
const extractor = await createExtractorFromFile({