Skip to content

Commit

Permalink
Merge pull request #34 from SoulHarsh007/main
Browse files Browse the repository at this point in the history
chore: update tests dependencies
  • Loading branch information
SoulHarsh007 authored Jun 7, 2024
2 parents 3524aa0 + de93fc3 commit a6cbb7b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
Binary file modified tests/bun.lockb
Binary file not shown.
28 changes: 18 additions & 10 deletions tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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`);
Expand Down
4 changes: 2 additions & 2 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit a6cbb7b

Please sign in to comment.