Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/server/src/cli/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,20 @@ it.layer(NodeServices.layer)("t3 install", (it) => {
// Another t3 earlier on PATH still runs first, so `t3` would not run this one.
const otherBin = path.join(root, "other-bin");
yield* fs.makeDirectory(otherBin);
yield* fs.writeFileString(path.join(otherBin, "t3"), "");
yield* fs.writeFileString(path.join(otherBin, "t3"), "", { mode: 0o755 });
const shadowed = yield* provide(installCli(), {
PATH: `${otherBin}:${path.join(root, "bin")}`,
});
assert.isFalse(shadowed.onPath);
assert.equal(shadowed.shadowedBy, path.join(otherBin, "t3"));
assert.isUndefined(shadowed.pathCommand);
yield* fs.remove(path.join(otherBin, "t3"));
yield* fs.makeDirectory(path.join(otherBin, "t3"));
const directory = yield* provide(installCli(), {
PATH: `${otherBin}:${path.join(root, "bin")}`,
});
assert.isTrue(directory.onPath);
assert.isUndefined(directory.shadowedBy);
const recorded = yield* fs.readFileString(path.join(runtimeDir, "launchers"));
assert.equal(recorded, `\n${yield* fs.realPath(path.join(root, "bin"))}/t3\n`);

Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/cli/install.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as HostProcess from "@t3tools/shared/HostProcess";
import { pathSetupCommand } from "@t3tools/shared/shell";
import { pathSetupCommand, resolveCommandPath } from "@t3tools/shared/shell";
import * as Console from "effect/Console";
import * as Duration from "effect/Duration";
import * as Effect from "effect/Effect";
Expand Down Expand Up @@ -156,7 +156,7 @@ export const installCli = Effect.fn("cli.install.install")(function* () {
if (!path.isAbsolute(entry) || detectCliRunner(`${entry}/`) !== null) continue;
for (const name of windows ? ["t3.cmd", "t3.exe"] : ["t3"]) {
const candidate = path.join(entry, name);
if (yield* fs.exists(candidate).pipe(Effect.orElseSucceed(() => false))) return candidate;
if (yield* resolveCommandPath(candidate, { env: environment })) return candidate;
}
}
return undefined;
Expand Down
Loading