test/runtime: align executor specs and bundled cli resolution

This commit is contained in:
ejclaw
2026-04-20 13:33:13 +09:00
parent fc1c377cf1
commit 8fff703f84
10 changed files with 384 additions and 43 deletions

View File

@@ -130,11 +130,11 @@ export function resolveBundledClaudeCodeExecutable(options?: {
*/
function defaultResolvePackageDir(pkg: string): string | null {
try {
// `require.resolve('<pkg>/package.json')` returns the absolute path to the
// package's package.json — its dirname is the package root.
// Resolve the package entrypoint instead of package.json because the SDK's
// exports map does not expose `./package.json`.
const req = createRequire(import.meta.url);
const pkgJson = req.resolve(`${pkg}/package.json`);
return path.dirname(pkgJson);
const entrypoint = req.resolve(pkg);
return path.dirname(entrypoint);
} catch {
return null;
}