Skip to content

Commit f60996b

Browse files
committed
Gate xz-utils hint to Linux only
The .tar.xz format is also used on macOS, where tar has built-in xz support. Only show the xz-utils installation hint on Linux where the tool may genuinely be missing. Adjust tests to verify platform-specific behavior.
1 parent e06904c commit f60996b

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/tools/impl/tinytex.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ async function install(
192192
async () => {
193193
const result = await unzip(pkgInfo.filePath);
194194
if (!result.success) {
195-
const hint = pkgInfo.filePath.endsWith(".tar.xz")
196-
? "\nOn Linux, you may need to install xz-utils (e.g., apt install xz-utils)."
195+
const hint = pkgInfo.filePath.endsWith(".tar.xz") && isLinux
196+
? "\nYou may need to install xz-utils (e.g., apt install xz-utils)."
197197
: "";
198198
throw new Error(
199199
`Failed to extract ${basename(pkgInfo.filePath)}.${hint}\n${result.stderr}`,

tests/unit/tools/tinytex.test.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { getLatestRelease } from "../../../src/tools/github.ts";
1414
import { GitHubRelease, InstallContext, PackageInfo } from "../../../src/tools/types.ts";
1515
import { join } from "../../../src/deno_ral/path.ts";
16+
import { isLinux } from "../../../src/deno_ral/platform.ts";
1617

1718
// ---- Pure logic tests for tinyTexPkgName ----
1819

@@ -210,7 +211,7 @@ unitTest(
210211
);
211212

212213
unitTest(
213-
"install - extraction failure for .tar.xz includes xz-utils hint",
214+
"install - extraction failure for .tar.xz includes xz-utils hint only on Linux",
214215
async () => {
215216
const workingDir = Deno.makeTempDirSync({ prefix: "quarto-tinytex-test" });
216217
try {
@@ -230,10 +231,17 @@ unitTest(
230231
await tinyTexInstallable.install(pkgInfo, context);
231232
throw new Error("Expected install to throw");
232233
} catch (e) {
233-
assert(
234-
e instanceof Error && e.message.includes("xz-utils"),
235-
`Error message should mention xz-utils, got: ${e}`,
236-
);
234+
if (isLinux) {
235+
assert(
236+
e instanceof Error && e.message.includes("xz-utils"),
237+
`On Linux, error should mention xz-utils, got: ${e}`,
238+
);
239+
} else {
240+
assert(
241+
e instanceof Error && !e.message.includes("xz-utils"),
242+
`On non-Linux, error should not mention xz-utils, got: ${e}`,
243+
);
244+
}
237245
}
238246
} finally {
239247
Deno.removeSync(workingDir, { recursive: true });

0 commit comments

Comments
 (0)