Skip to content

Commit 37bd0e4

Browse files
authored
fix(cli): fix spawn issue on windows (#2799)
1 parent f5abbe8 commit 37bd0e4

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

.changeset/stale-tips-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
fix `npx thirdweb` on windows when `thirdweb` is installed locally

packages/thirdweb/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,9 @@
202202
},
203203
"engines": {
204204
"node": ">=18"
205+
},
206+
"devDependencies": {
207+
"@types/cross-spawn": "^6.0.6",
208+
"cross-spawn": "7.0.3"
205209
}
206210
}

packages/thirdweb/src/cli/bin.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22

3-
import { execSync, spawn } from "node:child_process";
3+
import { execSync } from "node:child_process";
4+
import { spawn } from "cross-spawn";
45
import {
56
generate,
67
isValidChainIdAndContractAddress,
@@ -24,25 +25,24 @@ async function main() {
2425

2526
default: {
2627
const isWindows = /^win/.test(process.platform);
27-
let bunAvailable = false;
28-
// bun has no windows support yet anyways
29-
if (!isWindows) {
28+
29+
const isBunAvailable = (() => {
3030
try {
3131
const res = execSync("bun --version", {
3232
stdio: "ignore",
3333
encoding: "utf-8",
3434
});
3535
if (typeof res === "string" && res.indexOf(".") > -1) {
36-
bunAvailable = true;
36+
return true;
3737
}
38-
} catch {
39-
bunAvailable = false;
40-
}
41-
}
38+
} catch {}
39+
return false;
40+
})();
41+
4242
let runner = "npx";
4343

4444
switch (true) {
45-
case bunAvailable:
45+
case isBunAvailable:
4646
runner = "bun";
4747
break;
4848
case isWindows:

pnpm-lock.yaml

Lines changed: 31 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)