Skip to content

Commit 1593a58

Browse files
committed
fix layer analyzer failing to spawn bun when run outside the repo
1 parent cf0eaa4 commit 1593a58

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/layerAnalysis.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,19 @@ export const runLayerAnalysis = (projectPath: string = process.cwd()) =>
7575
// Get the path to layerResolverCli.ts
7676
const cliPath = path.resolve(__dirname, "./layerResolverCli.ts");
7777

78-
// Use Bun.spawn to run the analyzer with bun directly
79-
console.log(`Spawning: bun run ${cliPath} --json ${tsconfigPath}`);
78+
// Use Bun.spawn to run the analyzer with the same bun executable
79+
// Use process.execPath to get the path to the current bun executable
80+
// This ensures the analyzer works when installed globally or via npx
81+
const bunPath = process.execPath;
82+
console.log(`Spawning: ${bunPath} run ${cliPath} --json ${tsconfigPath}`);
8083

8184
// Store process reference for cleanup on interruption
8285
let spawnedProc: ReturnType<typeof Bun.spawn> | null = null;
8386

8487
const output = yield* Effect.tryPromise({
8588
try: async () => {
8689
const proc = Bun.spawn(
87-
["bun", "run", cliPath, "--json", tsconfigPath],
90+
[bunPath, "run", cliPath, "--json", tsconfigPath],
8891
{
8992
stdout: "pipe",
9093
stderr: "pipe",

0 commit comments

Comments
 (0)