diff --git a/tests/bun.lockb b/tests/bun.lockb index 82320f7..89c3a9f 100755 Binary files a/tests/bun.lockb and b/tests/bun.lockb differ diff --git a/tests/index.ts b/tests/index.ts index 1a0d888..c509cdf 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -2,8 +2,16 @@ import { mkdtemp, readdir } from "fs/promises"; import { tmpdir } from "os"; import { join, resolve } from "path"; import { parse } from "yaml"; + import logger from "./logger"; +const bsdtar = Bun.which("bsdtar"); +if (!bsdtar) { + logger.error("bsdtar not found in PATH"); + logger.error("Exiting with error code 1"); + process.exit(1); +} + type TNetInstallPackage = string | { name: string; description?: string }; type TNetInstallSubGroup = { @@ -53,9 +61,11 @@ type TPackageChooserData = { outputconditionkey: string; }; -const netInstallPath = resolve("../etc/calamares/modules/netinstall.yaml"); +const netInstallPath = resolve( + join(import.meta.dir, "..", "etc/calamares/modules/netinstall.yaml") +); const packageChooserPath = resolve( - "../etc/calamares/modules/packagechooser_DE.conf" + join(import.meta.dir, "..", "etc/calamares/modules/packagechooser_DE.conf") ); logger.info(`Reading netinstall.yaml from: ${netInstallPath}`); @@ -99,13 +109,11 @@ const discoverSubGroupPackages = ( }; const packages = [ - ...new Set( - [ - discoverSubGroupPackages(netInstallJSON), - discoverSubGroupPackages(packageChooserJSON.items), - ].flat() - ), -]; + discoverSubGroupPackages(netInstallJSON), + discoverSubGroupPackages(packageChooserJSON.items), +] + .flat() + .filter((x, i, a) => a.indexOf(x) === i); logger.info( `Found ${packages.length} unique packages in netinstall.yaml and packagechooser_DE.conf` @@ -151,7 +159,7 @@ await Promise.all( await Bun.write(db, body); logger.info(`Extracting ${repo.name} repository database`); try { - await Bun.spawn(["bsdtar", "-xf", db], { + await Bun.spawn([bsdtar, "-xf", db], { cwd: tempDir, }).exited; logger.success(`Extracted ${repo.name} repository database`); diff --git a/tests/package.json b/tests/package.json index 1934950..01092ed 100644 --- a/tests/package.json +++ b/tests/package.json @@ -3,10 +3,10 @@ "module": "index.ts", "type": "module", "devDependencies": { - "@types/bun": "1.0.12" + "@types/bun": "1.1.3" }, "dependencies": { "chalk": "5.3.0", - "yaml": "2.4.1" + "yaml": "2.4.3" } }