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
8 changes: 8 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ set -eu
repo="pingdotgg/t3code"
base_url="${T3CODE_RELEASE_BASE_URL:-https://github.com/${repo}/releases/download}"
t3_home="${T3CODE_HOME:-$HOME/.t3}"
case "$t3_home" in
/*) ;;
*)
# Preserve cwd's trailing newlines; trim only pwd's newline and the sentinel.
t3_cwd="$(pwd -P && printf .)"
t3_home="${t3_cwd%??}/$t3_home"
;;
esac
bin_dir="${T3CODE_INSTALL_BIN_DIR:-$HOME/.local/bin}"

fail() {
Expand Down
48 changes: 48 additions & 0 deletions scripts/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,54 @@ const nightlies = Array.from({ length: 100 }, (_, index) => ({
tag_name: `v1.2.4-nightly.20261020.${200 - index}`,
}));

describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("installer home", () => {
it("installs a relative home from a directory ending in a newline", async () => {
const temporaryRoot = await NodeFSP.realpath(
await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-install-home-")),
);
const root = NodePath.join(temporaryRoot, "cwd\n");
const homeName = "-custom home\\home\n";
const home = NodePath.join(root, homeName);
const version = "1.2.3";
const target = NodePath.join(home, "runtime/versions", version);
const launcher = NodePath.join(root, "bin/t3");
try {
await NodeFSP.mkdir(target, { recursive: true });
await NodeFSP.writeFile(NodePath.join(target, ".install-complete"), `${version}\n`);
await NodeFSP.writeFile(NodePath.join(target, "t3"), "#!/bin/sh\necho 't3 v1.2.3'\n", {
mode: 0o755,
});
const { status, stdout, stderr } = NodeChildProcess.spawnSync(
"sh",
[NodePath.resolve(import.meta.dirname, "install.sh")],
{
cwd: root,
env: {
...process.env,
HOME: root,
T3CODE_HOME: homeName,
T3CODE_VERSION: version,
T3CODE_INSTALL_BIN_DIR: NodePath.dirname(launcher),
T3CODE_RELEASE_BASE_URL: "http://127.0.0.1:1",
},
encoding: "utf8",
},
);
expect(status, stdout + stderr).toBe(0);
expect(stderr).toContain(`Installed T3 Code ${version}`);
expect(await NodeFSP.readlink(launcher)).toBe(NodePath.join(target, "t3"));
expect(
NodeChildProcess.execFileSync(launcher, ["--version"], {
cwd: NodeOS.tmpdir(),
encoding: "utf8",
}).trim(),
).toBe("t3 v1.2.3");
} finally {
await NodeFSP.rm(temporaryRoot, { recursive: true, force: true });
}
});
});

// regression: #22490
describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("installer channel lookup", () => {
it.each([
Expand Down
Loading