Files
hyperframes/packages/cli/src/commands/lambda/repoRoot.test.ts
T
Miguel Ángel 4178a8f95d fix(cli): reject extra positional arguments on every command (#4905)
* fix(cli): reject extra positional arguments on every command

* fix(cli): read the command name without assuming a resolved meta

* fix(cli): join free-text words for catalog and tts, reject a bad repo root

* test(cli): load the listed commands through static imports

* fix(cli): keep a tts file path out of the word join and read the parsed json flag

* fix(cli): apply the file exception only to a tts .txt path

* fix(cli): keep usageLine private and test the json fallback for undeclared json

* fix(cli): keep extra arguments and the repo root value out of telemetry

* test(cli): type the skills update lookup

* fix(cli): read json mode from the parsed flag, reject tts words with --text-file, restore add's hint

* fix(cli): check tts words with --text-file before --list and test --json=false
2026-10-02 18:34:53 +00:00

35 lines
1.2 KiB
TypeScript

import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import { repoRoot } from "./repoRoot.js";
describe("repoRoot", () => {
const dirs: string[] = [];
const tempDir = () => {
const dir = mkdtempSync(join(tmpdir(), "hf-repo-root-"));
dirs.push(dir);
return dir;
};
afterEach(() => {
vi.unstubAllEnvs();
for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true });
});
it("returns HYPERFRAMES_REPO_ROOT when it is a hyperframes checkout", () => {
const root = tempDir();
mkdirSync(join(root, "packages", "aws-lambda"), { recursive: true });
writeFileSync(join(root, "packages", "aws-lambda", "package.json"), "{}");
vi.stubEnv("HYPERFRAMES_REPO_ROOT", root);
expect(repoRoot()).toBe(root);
});
it("throws on a HYPERFRAMES_REPO_ROOT that is not a checkout instead of ignoring it", () => {
const root = tempDir();
vi.stubEnv("HYPERFRAMES_REPO_ROOT", root);
expect(() => repoRoot()).toThrow("HYPERFRAMES_REPO_ROOT is not a hyperframes checkout");
expect(() => repoRoot()).not.toThrow(root);
});
});