GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(cli): npx no longer skips the install offer for a directory or no… · pingdotgg/t3code@1df56f6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/cli
    • install.test.ts
    • install.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/cli/install.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/cli/install.test.ts
+16-1Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,32 @@ it.layer(NodeServices.layer)("t3 install", (it) => {
212212
const globalBin = path.join(root, "global-bin");
213213
yield* fs.makeDirectory(globalBin);
214214
yield* fs.writeFileString(path.join(globalBin, "t3"), "");
215+
yield* fs.chmod(path.join(globalBin, "t3"), 0o755);
215216
yield* offer(false, { env: { PATH: globalBin } });
216217
assert.equal(asked, 0);
217218
assert.isFalse(yield* fs.exists(link));
218219

219-
// A runner's own .bin on PATH is not an installed t3.
220+
// A directory or non-executable file named `t3` on PATH is not an installed t3.
221+
const dirBin = path.join(root, "dir-bin");
222+
yield* fs.makeDirectory(path.join(dirBin, "t3"), { recursive: true });
223+
const nonExecBin = path.join(root, "non-exec-bin");
224+
yield* fs.makeDirectory(nonExecBin);
225+
yield* fs.writeFileString(path.join(nonExecBin, "t3"), "");
226+
assert.isFalse(yield* offer(undefined, { env: { PATH: dirBin } }));
227+
assert.equal(asked, 1);
228+
assert.isFalse(yield* offer(undefined, { env: { PATH: nonExecBin } }));
229+
assert.equal(asked, 2);
230+
asked = 0;
231+
232+
// A runner's own .bin on PATH, even found through a bare launcher record, is not an installed t3.
220233
const npxBin = path.join(npmPackage, "../.bin");
221234
const pnpmBin = path.join(root, ".cache/pnpm/dlx/abc/node_modules/.bin");
222235
for (const bin of [npxBin, pnpmBin]) {
223236
yield* fs.makeDirectory(bin, { recursive: true });
224237
yield* fs.writeFileString(path.join(bin, "t3"), "");
238+
yield* fs.chmod(path.join(bin, "t3"), 0o755);
225239
}
240+
yield* fs.writeFileString(path.join(runtimeDir, "launchers"), "t3\n");
226241
assert.isFalse(yield* offer(undefined, { env: { PATH: `${npxBin}:${pnpmBin}` } }));
227242
assert.equal(asked, 1);
228243
assert.isFalse(yield* fs.exists(path.join(runtimeDir, "install-prompt-declined")));
Collapse file

‎apps/server/src/cli/install.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/cli/install.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export const offerCliInstall = Effect.fn("cli.install.offer")(function* <E, R, E
322322
.readFileString(path.join(runtimeDir, "launchers"))
323323
.pipe(Effect.orElseSucceed(() => ""));
324324
const candidates = [
325-
...launchers.split(/\r?\n/).filter(Boolean),
325+
...launchers.split(/\r?\n/).filter((launcher) => path.isAbsolute(launcher)),
326326
path.join(path.dirname(runtimeDir), "bin", windows ? "t3.cmd" : "t3"),
327327
...(environment.PATH ?? environment.Path ?? "")
328328
.split(windows ? ";" : ":")
@@ -332,7 +332,7 @@ export const offerCliInstall = Effect.fn("cli.install.offer")(function* <E, R, E
332332
.flatMap((directory) => names.map((name) => path.join(directory, name))),
333333
];
334334
for (const candidate of candidates) {
335-
if (yield* fs.exists(candidate).pipe(Effect.orElseSucceed(() => false))) return true;
335+
if (yield* resolveCommandPath(candidate, { env: environment })) return true;
336336
}
337337

338338
const declinedFile = path.join(runtimeDir, "install-prompt-declined");

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.