fix(setup): register a stable launcher when run through bunx (#1731)
Setup run through bunx or bun x registered the bin inside bun's temporary package cache. Detect bun's package-runner launch from npm_command=exec with a bun user agent and register the pinned bunx launcher, wrapped in cmd.exe on Windows like the npx launcher. Doctor, update maintenance and uninstall recognize it as REA-owned, and setup's printed commands name the runner that launched it. Read the runner variables case-insensitively on Windows, where the CLI environment snapshot upper-cases variable names and setup run through npx also fell back to the cache path. Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -12,6 +12,12 @@ import { systemUninstallHost } from "./application/Uninstall.js";
|
||||
import { runUpdateCommand } from "./application/UpdateRuntime.js";
|
||||
import { createSystemDoctorHost } from "./doctorRuntime.js";
|
||||
import { PRODUCT_IDENTITY } from "./identity.js";
|
||||
import {
|
||||
invokingPackageRunner,
|
||||
packageRunnerRegistrationCommand,
|
||||
withoutPackageRunnerIdentity,
|
||||
} from "./application/ClientRegistrationIdentity.js";
|
||||
import { snapshotEnvironment } from "./process/snapshotEnvironment.js";
|
||||
|
||||
afterEach(() => vi.unstubAllEnvs());
|
||||
|
||||
@@ -98,3 +104,27 @@ it("passes only selected environment to updater subprocesses and drops npm invoc
|
||||
);
|
||||
expect(result).toEqual({ ok: true, value: '{"marker":"selected"}' });
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ userAgent: "npm/10.9.0 node/v24.11.0 win32 x64", runner: "npx" },
|
||||
{ userAgent: "bun/1.4.2 npm/? node/v26.3.0 win32 x64", runner: "bunx" },
|
||||
] as const)(
|
||||
"registers the $runner launcher from a Windows CLI environment snapshot",
|
||||
({ userAgent, runner }) => {
|
||||
// The CLI snapshot canonicalizes Windows variable names to upper case.
|
||||
const environment = snapshotEnvironment(
|
||||
{ npm_command: "exec", npm_config_user_agent: userAgent },
|
||||
"win32",
|
||||
);
|
||||
expect(invokingPackageRunner(environment, "win32")).toBe(runner);
|
||||
expect(
|
||||
systemSetupHost(
|
||||
createDoctorHostFixture({ platform: "win32" }),
|
||||
environment,
|
||||
).registrationCommand,
|
||||
).toEqual(packageRunnerRegistrationCommand(runner, "win32"));
|
||||
expect(withoutPackageRunnerIdentity(environment, "win32")).toEqual({
|
||||
NPM_CONFIG_USER_AGENT: userAgent,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user