Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion scripts/force-desktop-full-download.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { gunzipSync, gzipSync } from "node:zlib";
import { afterEach, describe, expect, it } from "vitest";
import { forceDesktopFullDownload } from "./force-desktop-full-download.js";
import {
forceDesktopFullDownload,
parseForceFullDownloadDirectory,
} from "./force-desktop-full-download.js";

const roots: string[] = [];

Expand All @@ -29,6 +32,15 @@ afterEach(async () => {
});

describe("force-desktop-full-download", () => {
it("accepts pnpm's optional argument separator", () => {
expect(parseForceFullDownloadDirectory(["--directory", "release/desktop"])).toBe(
"release/desktop"
);
expect(parseForceFullDownloadDirectory(["--", "--directory", "release/desktop"])).toBe(
"release/desktop"
);
});

it("marks the target blockmap as incompatible so legacy clients fall back to the full installer", async () => {
const fixture = await createFixture();

Expand Down
11 changes: 7 additions & 4 deletions scripts/force-desktop-full-download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,18 @@ export async function forceDesktopFullDownload(
return { blockmapPath, originalVersion, forcedVersion, changed: true };
}

function parseDirectory(argv: string[]): string {
if (argv.length !== 2 || argv[0] !== "--directory" || !argv[1]) {
export function parseForceFullDownloadDirectory(argv: string[]): string {
const args = argv[0] === "--" ? argv.slice(1) : argv;
if (args.length !== 2 || args[0] !== "--directory" || !args[1]) {
throw new Error("Usage: force-desktop-full-download --directory <release-directory>");
}
return argv[1];
return args[1];
}

async function main(): Promise<void> {
const result = await forceDesktopFullDownload(parseDirectory(process.argv.slice(2)));
const result = await forceDesktopFullDownload(
parseForceFullDownloadDirectory(process.argv.slice(2))
);
success(
`${result.changed ? "Marked" : "Verified"} Desktop blockmap for full installer download: ${result.blockmapPath}`
);
Expand Down
Loading