Skip to content

Commit

Permalink
fix: just log warning if ubuntu version is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovRoman committed Dec 2, 2024
1 parent 6f9aeaf commit 642e41f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/browser-installer/ubuntu-packages/apt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ const unpackUbuntuPackages = async (packagesDir: string, destination: string): P
};

export const installUbuntuPackages = async (packages: string[], destination: string): Promise<void> => {
if (!packages) {
browserInstallerDebug(`There are no ubuntu packages to install`);

return fs.ensureDir(destination);
}

const withRecursiveDependencies = await resolveTransitiveDependencies(packages);

browserInstallerDebug(`Resolved direct packages to ${withRecursiveDependencies.length} dependencies`);
Expand Down
9 changes: 7 additions & 2 deletions src/browser-installer/ubuntu-packages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ const readUbuntuPackageDependencies = async (ubuntuMilestone: string): Promise<s
try {
return await fs.readJSON(getDependenciesArrayFilePath(ubuntuMilestone));
} catch (_) {
throw new Error(
`Unable to read ubuntu dependencies for Ubuntu@${ubuntuMilestone}, as this version currently not supported`,
logger.warn(
[
`Unable to read ubuntu dependencies for Ubuntu@${ubuntuMilestone}, as this version currently not supported`,
`Assuming all necessary packages are installed already`,
].join("\n"),
);

return [];
}
};

Expand Down
20 changes: 19 additions & 1 deletion test/src/browser-installer/ubuntu-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe("browser-installer/ubuntu-packages", () => {

let fsStub: Record<keyof typeof import("fs-extra"), SinonStub>;
let loggerLogStub: SinonStub;
let loggerWarnStub: SinonStub;
let installUbuntuPackagesStub: SinonStub;
let getUbuntuMilestoneStub: SinonStub;

Expand All @@ -28,14 +29,15 @@ describe("browser-installer/ubuntu-packages", () => {
} as Record<keyof typeof import("fs-extra"), SinonStub>;

loggerLogStub = sandbox.stub();
loggerWarnStub = sandbox.stub();
installUbuntuPackagesStub = sandbox.stub();
getUbuntuMilestoneStub = sandbox.stub().resolves("20");

const ubuntuPackages = proxyquire("../../../src/browser-installer/ubuntu-packages", {
"fs-extra": fsStub,
"./apt": { installUbuntuPackages: installUbuntuPackagesStub },
"./utils": { getUbuntuMilestone: getUbuntuMilestoneStub },
"../../utils/logger": { log: loggerLogStub },
"../../utils/logger": { log: loggerLogStub, warn: loggerWarnStub },
});

({ writeUbuntuPackageDependencies, installUbuntuPackageDependencies, getUbuntuLinkerEnv } = ubuntuPackages);
Expand Down Expand Up @@ -97,6 +99,22 @@ describe("browser-installer/ubuntu-packages", () => {
assert.notCalled(loggerLogStub);
assert.notCalled(installUbuntuPackagesStub);
});

it("should log warning if current ubuntu version is not supported", async () => {
getUbuntuMilestoneStub.resolves("100500");
fsStub.readJSON.withArgs(sinon.match("ubuntu-100500-dependencies.json")).rejects(new Error("No such file"));

await installUbuntuPackageDependencies();

assert.calledOnceWith(
loggerWarnStub,
[
`Unable to read ubuntu dependencies for Ubuntu@100500, as this version currently not supported`,
`Assuming all necessary packages are installed already`,
].join("\n"),
);
assert.calledOnceWith(installUbuntuPackagesStub, []);
});
});

describe("getUbuntuLinkerEnv", () => {
Expand Down

0 comments on commit 642e41f

Please sign in to comment.