Skip to content

Commit

Permalink
fix: global bin discovery fixed if found on any level globally
Browse files Browse the repository at this point in the history
  • Loading branch information
milaninfy committed Jun 5, 2024
1 parent 1fdf327 commit 7f945d2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions workspaces/libnpmexec/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,20 @@ const exec = async (opts) => {
const globalTree = await globalArb.loadActual()
const { manifest: globalManifest, node: globalNode } =
await missingFromTree({ spec, tree: globalTree, flatOptions })
if (globalNode) {
const newPath = globalNode.binPaths.filter(p => p.endsWith(args[0]))[0]
binPaths.push(newPath.replace(args[0], ''))
return await run()
}
if (!globalManifest && await fileExists(`${globalBin}/${args[0]}`)) {
binPaths.push(globalBin)
return await run()
}
// check for the bin in the global tree at any level deep
// if we found a node matched with spec, we can use it to get the bin path from it
const foundBinPaths = globalNode
?.binPaths
?.filter(async p => await fileExists(`${dirname(p)}/${args[0]}`))

if (foundBinPaths?.length) {
binPaths.push(dirname(foundBinPaths[0]))
return await run()
}
}
}

Expand Down

0 comments on commit 7f945d2

Please sign in to comment.