From c6744c9b4c5415a55ee4f5845f6ae80d594aaea9 Mon Sep 17 00:00:00 2001 From: Fabio Gartenmann <137318798+artiphishle@users.noreply.github.com> Date: Sun, 10 May 2026 19:15:02 +0200 Subject: [PATCH 1/3] fix: resolve bundled tool bins through package entrypoints --- src/internal/runPackageBin.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/internal/runPackageBin.ts b/src/internal/runPackageBin.ts index bad0dcd..c4c6237 100644 --- a/src/internal/runPackageBin.ts +++ b/src/internal/runPackageBin.ts @@ -1,7 +1,7 @@ import { spawn } from 'node:child_process'; -import { readFileSync } from 'node:fs'; +import { existsSync, readFileSync } from 'node:fs'; import { createRequire } from 'node:module'; -import { dirname, resolve } from 'node:path'; +import { dirname, join, resolve } from 'node:path'; const require = createRequire(import.meta.url); @@ -9,8 +9,24 @@ function isRecord(value: unknown): value is Record { return typeof value === 'object' && value !== null; } +function findPackageJsonPath(packageName: string): string { + let currentDirectory = dirname(require.resolve(packageName)); + + while (currentDirectory !== dirname(currentDirectory)) { + const packageJsonPath = join(currentDirectory, 'package.json'); + + if (existsSync(packageJsonPath)) { + return packageJsonPath; + } + + currentDirectory = dirname(currentDirectory); + } + + throw new Error(`Could not find package metadata for ${packageName}.`); +} + function readPackageBinPath(packageName: string, binName: string): string { - const packageJsonPath = require.resolve(`${packageName}/package.json`); + const packageJsonPath = findPackageJsonPath(packageName); const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as unknown; if (!isRecord(packageJson)) { From 20927769502c118a41c97a8a5974ee47d1815531 Mon Sep 17 00:00:00 2001 From: Fabio Gartenmann <137318798+artiphishle@users.noreply.github.com> Date: Sun, 10 May 2026 19:18:22 +0200 Subject: [PATCH 2/3] chore: add binary wrapper fix changeset --- .changeset/sharp-bins-resolve.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sharp-bins-resolve.md diff --git a/.changeset/sharp-bins-resolve.md b/.changeset/sharp-bins-resolve.md new file mode 100644 index 0000000..5c62a8b --- /dev/null +++ b/.changeset/sharp-bins-resolve.md @@ -0,0 +1,5 @@ +--- +"@ankhorage/devtools": patch +--- + +Fix bundled tool binary wrappers for packages that do not export their package metadata. From a43730496d018f71c262ab1f13c9a7dae3a80d2b Mon Sep 17 00:00:00 2001 From: artiphishle Date: Sun, 10 May 2026 19:20:47 +0200 Subject: [PATCH 3/3] chore(prettier): format --- .changeset/sharp-bins-resolve.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/sharp-bins-resolve.md b/.changeset/sharp-bins-resolve.md index 5c62a8b..dcc1144 100644 --- a/.changeset/sharp-bins-resolve.md +++ b/.changeset/sharp-bins-resolve.md @@ -1,5 +1,5 @@ --- -"@ankhorage/devtools": patch +'@ankhorage/devtools': patch --- Fix bundled tool binary wrappers for packages that do not export their package metadata.