44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
buildSplitWindowArgs,
|
|
buildWrapperShellCommand,
|
|
isInsideTmux,
|
|
} from "./tmux.ts";
|
|
|
|
test("isInsideTmux reads the TMUX environment variable", () => {
|
|
assert.equal(isInsideTmux({ TMUX: "/tmp/tmux-1000/default,123,0" } as NodeJS.ProcessEnv), true);
|
|
assert.equal(isInsideTmux({} as NodeJS.ProcessEnv), false);
|
|
});
|
|
|
|
test("buildWrapperShellCommand single-quotes paths safely", () => {
|
|
const command = buildWrapperShellCommand({
|
|
nodePath: "/usr/local/bin/node",
|
|
wrapperPath: "/repo/subagents/src/wrapper/cli.mjs",
|
|
metaPath: "/repo/.pi/subagents/runs/run-1/meta.json",
|
|
});
|
|
|
|
assert.equal(
|
|
command,
|
|
"'/usr/local/bin/node' '/repo/subagents/src/wrapper/cli.mjs' '/repo/.pi/subagents/runs/run-1/meta.json'",
|
|
);
|
|
});
|
|
|
|
test("buildSplitWindowArgs targets the current window and cwd", () => {
|
|
assert.deepEqual(buildSplitWindowArgs({
|
|
windowId: "@7",
|
|
cwd: "/repo",
|
|
command: "'node' '/wrapper.mjs' '/meta.json'",
|
|
}), [
|
|
"split-window",
|
|
"-P",
|
|
"-F",
|
|
"#{pane_id}",
|
|
"-t",
|
|
"@7",
|
|
"-c",
|
|
"/repo",
|
|
"'node' '/wrapper.mjs' '/meta.json'",
|
|
]);
|
|
});
|