Skip to content

Commit ba97889

Browse files
Merge pull request #135 from xuzhongpeng/fix/dev-script-path-resolution
fix: resolve absolute path in dev.ts for cross-directory execution
2 parents 918defa + 714ef13 commit ba97889

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

scripts/dev.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44
* via Bun's -d flag (bunfig.toml [define] doesn't propagate to
55
* dynamically imported modules at runtime).
66
*/
7+
import { join, dirname } from "node:path";
8+
import { fileURLToPath } from "node:url";
79
import { getMacroDefines } from "./defines.ts";
810

11+
// Resolve project root from this script's location
12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = dirname(__filename);
14+
const projectRoot = join(__dirname, "..");
15+
const cliPath = join(projectRoot, "src/entrypoints/cli.tsx");
16+
917
const defines = getMacroDefines();
1018

1119
const defineArgs = Object.entries(defines).flatMap(([k, v]) => [
@@ -32,8 +40,8 @@ const inspectArgs = process.env.BUN_INSPECT
3240
: [];
3341

3442
const result = Bun.spawnSync(
35-
["bun", ...inspectArgs, "run", ...defineArgs, ...featureArgs, "src/entrypoints/cli.tsx", ...process.argv.slice(2)],
36-
{ stdio: ["inherit", "inherit", "inherit"] },
43+
["bun", ...inspectArgs, "run", ...defineArgs, ...featureArgs, cliPath, ...process.argv.slice(2)],
44+
{ stdio: ["inherit", "inherit", "inherit"], cwd: projectRoot },
3745
);
3846

3947
process.exit(result.exitCode ?? 0);

0 commit comments

Comments
 (0)