Skip to content

Commit e970d43

Browse files
authored
Merge pull request #57 from pkgxdev/conservative-shims
Only shim directly requested things
2 parents 2762991 + e874c76 commit e970d43

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ jobs:
6262
- run: ./pkgm.ts shim semverator
6363
- run: ~/.local/bin/semverator validate 1.0.0
6464

65+
# tests shims do not shim deps
66+
- run: ./pkgm.ts shim node
67+
- run: test ! -d ~/.local/bin/openssl
68+
6569
- run: ./pkgm.ts i hyperfine@1.18
6670
- run: ./pkgm.ts outdated | grep hyperfine
6771
- run: if pkgx semverator satisfies '>=1.19' "$(hyperfine --version | cut -f 2 -d ' ')"; then false; fi

pkgm.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { dirname, join } from "jsr:@std/path@^1";
1212
import { ensureDir, existsSync, walk } from "jsr:@std/fs@^1";
1313
import { parseArgs } from "jsr:@std/cli@^1";
1414
import hydrate from "https://deno.land/x/libpkgx@v0.20.3/src/plumbing/hydrate.ts";
15+
import { basename } from "node:path";
1516

1617
function 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

Comments
 (0)