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" ;
79import { 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+
917const defines = getMacroDefines ( ) ;
1018
1119const defineArgs = Object . entries ( defines ) . flatMap ( ( [ k , v ] ) => [
@@ -32,8 +40,8 @@ const inspectArgs = process.env.BUN_INSPECT
3240 : [ ] ;
3341
3442const 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
3947process . exit ( result . exitCode ?? 0 ) ;
0 commit comments