diff --git a/install.sh b/install.sh index d9993da1..80be1f9f 100644 --- a/install.sh +++ b/install.sh @@ -70,7 +70,7 @@ resolve_version() { ;; *) echo "Error: unexpected response from GitHub releases API." >&2 - echo "Response (truncated): $(printf '%s' "$response" | head -c 200)" >&2 + echo "Response (truncated): $(printf '%s' "$response" | cut -c1-200)" >&2 exit 1 ;; esac diff --git a/tests/commands/plugin/index.test.ts b/tests/commands/plugin/index.test.ts index ade86384..737fc688 100644 --- a/tests/commands/plugin/index.test.ts +++ b/tests/commands/plugin/index.test.ts @@ -4,32 +4,31 @@ import { Command } from "@commander-js/extra-typings"; import { registerPluginCommand } from "../../../src/commands/plugin/index"; +const createProgramAndPlugin = () => { + const program = new Command(); + registerPluginCommand(program); + const plugin = program.commands.find((c) => c.name() === "plugin")!; + return { program, plugin }; +}; + describe("registerPluginCommand", () => { test("registers 'plugin' as a subcommand", () => { - const program = new Command(); - registerPluginCommand(program); - const sub = program.commands.find((c) => c.name() === "plugin"); - expect(sub).toBeDefined(); + const { plugin } = createProgramAndPlugin(); + expect(plugin).toBeDefined(); }); test("has a description", () => { - const program = new Command(); - registerPluginCommand(program); - const sub = program.commands.find((c) => c.name() === "plugin")!; - expect(sub.description()).toBeTruthy(); + const { plugin } = createProgramAndPlugin(); + expect(plugin.description()).toBeTruthy(); }); test("registers 'url' subcommand", () => { - const program = new Command(); - registerPluginCommand(program); - const plugin = program.commands.find((c) => c.name() === "plugin")!; + const { plugin } = createProgramAndPlugin(); expect(plugin.commands.find((c) => c.name() === "url")).toBeDefined(); }); test("registers 'install' subcommand", () => { - const program = new Command(); - registerPluginCommand(program); - const plugin = program.commands.find((c) => c.name() === "plugin")!; + const { plugin } = createProgramAndPlugin(); expect(plugin.commands.find((c) => c.name() === "install")).toBeDefined(); }); }); diff --git a/tests/helpers/binary-upgrade.test.ts b/tests/helpers/binary-upgrade.test.ts index 88bf2948..68c81d6c 100644 --- a/tests/helpers/binary-upgrade.test.ts +++ b/tests/helpers/binary-upgrade.test.ts @@ -29,9 +29,9 @@ describe("getArtifactInfo", () => { test("returns .tar.gz extension for non-win32", () => { const info = getArtifactInfo(); if (process.platform === "win32") return; - if (info === null) return; - expect(info.ext).toBe(".tar.gz"); - expect(info.binaryName).toBe("archgate"); + expect(info).not.toBeNull(); + expect(info!.ext).toBe(".tar.gz"); + expect(info!.binaryName).toBe("archgate"); }); });