@@ -12,6 +12,7 @@ import { dirname, join } from "jsr:@std/path@^1";
1212import { ensureDir , existsSync , walk } from "jsr:@std/fs@^1" ;
1313import { parseArgs } from "jsr:@std/cli@^1" ;
1414import hydrate from "https://deno.land/x/libpkgx@v0.20.3/src/plumbing/hydrate.ts" ;
15+ import { basename } from "node:path" ;
1516
1617function standardPath ( ) {
1718 let path = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" ;
@@ -211,7 +212,22 @@ async function shim(args: string[], basePath: string) {
211212
212213 const json = ( await query_pkgx ( pkgx , args ) ) [ 0 ] ;
213214
215+ const projects_we_care_about = [ ] ;
214216 for ( const pkg of json . pkgs ) {
217+ const cmds = await hooks . usePantry ( ) . project ( pkg . pkg . project ) . provides ( ) ;
218+ const set = new Set ( cmds . map ( ( x ) => basename ( x ) ) ) ;
219+ if ( ! args . some ( ( x ) => set . has ( x ) ) ) continue ;
220+ const companions = await hooks . usePantry ( ) . project ( pkg . pkg . project )
221+ . companions ( ) ;
222+ projects_we_care_about . push (
223+ pkg . pkg . project ,
224+ ...companions . map ( ( x ) => x . project ) ,
225+ ) ;
226+ }
227+
228+ for ( const pkg of json . pkgs ) {
229+ if ( ! projects_we_care_about . includes ( pkg . pkg . project ) ) continue ;
230+
215231 for ( const bin of [ "bin" , "sbin" ] ) {
216232 const bin_prefix = pkg . path . join ( bin ) ;
217233 if ( ! bin_prefix . exists ( ) ) continue ;
0 commit comments