mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
fix: copy unrar.wasm as part of the postinstallation process
This commit is contained in:
parent
8b304dc46c
commit
8caea2893d
4 changed files with 12 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
||||||
node_modules
|
node_modules
|
||||||
hydra-download-manager
|
hydra-download-manager
|
||||||
fastlist.exe
|
fastlist.exe
|
||||||
|
unrar.wasm
|
||||||
__pycache__
|
__pycache__
|
||||||
dist
|
dist
|
||||||
out
|
out
|
||||||
|
|
|
@ -6,6 +6,7 @@ extraResources:
|
||||||
- hydra-download-manager
|
- hydra-download-manager
|
||||||
- hydra.db
|
- hydra.db
|
||||||
- fastlist.exe
|
- fastlist.exe
|
||||||
|
- unrar.wasm
|
||||||
files:
|
files:
|
||||||
- "!**/.vscode/*"
|
- "!**/.vscode/*"
|
||||||
- "!src/*"
|
- "!src/*"
|
||||||
|
|
|
@ -6,3 +6,5 @@ if (process.platform === "win32") {
|
||||||
"fastlist.exe"
|
"fastlist.exe"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.copyFileSync("node_modules/node-unrar-js/esm/js/unrar.wasm", "unrar.wasm");
|
|
@ -1,12 +1,18 @@
|
||||||
import { Extractor, createExtractorFromFile } from "node-unrar-js";
|
import { Extractor, createExtractorFromFile } from "node-unrar-js";
|
||||||
import fs from "node:fs";
|
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(
|
const wasmBinary = fs.readFileSync(
|
||||||
require.resolve("node-unrar-js/esm/js/unrar.wasm")
|
require.resolve(wasmPath)
|
||||||
);
|
);
|
||||||
|
|
||||||
export class Unrar {
|
export class Unrar {
|
||||||
private constructor(private extractor: Extractor<Uint8Array>) {}
|
private constructor(private extractor: Extractor<Uint8Array>) { }
|
||||||
|
|
||||||
static async fromFilePath(filePath: string, targetFolder: string) {
|
static async fromFilePath(filePath: string, targetFolder: string) {
|
||||||
const extractor = await createExtractorFromFile({
|
const extractor = await createExtractorFromFile({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue