Skip to content

Commit 43f87e8

Browse files
t3dotggclaude
andcommitted
Normalize Windows path separators in runner detection
Review bots correctly flagged that pnpm dlx and bunx entry paths use backslashes on Windows and would fall back to the bare `t3` suggestion. Normalize separators once and match forward-slash segments, and add the Windows pnpm-cache/dlx layout. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 4ecb6fc commit 43f87e8

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

‎apps/server/src/cli/invocation.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,20 @@ it("detects package runners from their cache entry paths", () => {
1818
detectCliRunner("/home/theo/.local/share/pnpm/.pnpm/dlx/abc/node_modules/t3/dist/bin.mjs"),
1919
"pnpm dlx",
2020
);
21+
assert.equal(
22+
detectCliRunner(
23+
"C:\\Users\\theo\\AppData\\Local\\pnpm-cache\\dlx\\abc\\node_modules\\t3\\dist\\bin.mjs",
24+
),
25+
"pnpm dlx",
26+
);
2127
assert.equal(detectCliRunner("/home/theo/.bun/install/cache/[email protected]/dist/bin.mjs"), "bunx");
2228
assert.equal(detectCliRunner("/tmp/bunx-1000-t3@latest/node_modules/t3/dist/bin.mjs"), "bunx");
29+
assert.equal(
30+
detectCliRunner(
31+
"C:\\Users\\theo\\AppData\\Local\\Temp\\bunx-0-t3@latest\\node_modules\\t3\\dist\\bin.mjs",
32+
),
33+
"bunx",
34+
);
2335
});
2436

2537
it("treats stable installs as direct invocations", () => {

‎apps/server/src/cli/invocation.ts‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,26 @@ export type CliRunner = "npx" | "pnpm dlx" | "bunx";
1111
* package runner executes out of a distinctive cache/temp layout:
1212
*
1313
* npx ~/.npm/_npx/<hash>/node_modules/...
14-
* pnpm dlx ~/.cache/pnpm/dlx/... or $PNPM_HOME/.pnpm/dlx/...
14+
* pnpm dlx ~/.cache/pnpm/dlx/..., $PNPM_HOME/.pnpm/dlx/...,
15+
* or %LOCALAPPDATA%/pnpm-cache/dlx/... on Windows
1516
* bunx ~/.bun/install/cache/... or $TMPDIR/bunx-<uid>-<spec>/...
1617
*
1718
* Global installs and repo checkouts match none of these and return null.
1819
* Detection is best-effort; callers must fail closed to a plain `t3` command.
1920
*/
2021
export function detectCliRunner(entryPath: string): CliRunner | null {
21-
if (entryPath.includes("/_npx/") || entryPath.includes("\\_npx\\")) {
22+
const path = entryPath.replaceAll("\\", "/");
23+
if (path.includes("/_npx/")) {
2224
return "npx";
2325
}
24-
if (entryPath.includes("/pnpm/dlx/") || entryPath.includes("/.pnpm/dlx/")) {
25-
return "pnpm dlx";
26-
}
2726
if (
28-
entryPath.includes("/.bun/install/cache/") ||
29-
entryPath.includes("/bunx-") ||
30-
entryPath.includes("\\bunx-")
27+
path.includes("/pnpm/dlx/") ||
28+
path.includes("/.pnpm/dlx/") ||
29+
path.includes("/pnpm-cache/dlx/")
3130
) {
31+
return "pnpm dlx";
32+
}
33+
if (path.includes("/.bun/install/cache/") || path.includes("/bunx-")) {
3234
return "bunx";
3335
}
3436
return null;

0 commit comments

Comments
 (0)