fix(test): stub pnpm in pre-commit hook fixture
This commit is contained in:
parent
a2174f1ff1
commit
1fb30fbf78
@ -18,6 +18,13 @@ const run = (cwd: string, cmd: string, args: string[] = [], env?: NodeJS.Process
|
|||||||
}).trim();
|
}).trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function writeExecutable(dir: string, name: string, contents: string): void {
|
||||||
|
writeFileSync(path.join(dir, name), contents, {
|
||||||
|
encoding: "utf8",
|
||||||
|
mode: 0o755,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
describe("git-hooks/pre-commit (integration)", () => {
|
describe("git-hooks/pre-commit (integration)", () => {
|
||||||
it("does not treat staged filenames as git-add flags (e.g. --all)", () => {
|
it("does not treat staged filenames as git-add flags (e.g. --all)", () => {
|
||||||
const dir = mkdtempSync(path.join(os.tmpdir(), "openclaw-pre-commit-"));
|
const dir = mkdtempSync(path.join(os.tmpdir(), "openclaw-pre-commit-"));
|
||||||
@ -45,10 +52,10 @@ describe("git-hooks/pre-commit (integration)", () => {
|
|||||||
);
|
);
|
||||||
const fakeBinDir = path.join(dir, "bin");
|
const fakeBinDir = path.join(dir, "bin");
|
||||||
mkdirSync(fakeBinDir, { recursive: true });
|
mkdirSync(fakeBinDir, { recursive: true });
|
||||||
writeFileSync(path.join(fakeBinDir, "node"), "#!/usr/bin/env bash\nexit 0\n", {
|
writeExecutable(fakeBinDir, "node", "#!/usr/bin/env bash\nexit 0\n");
|
||||||
encoding: "utf8",
|
// The hook ends with `pnpm check`, but this fixture is only exercising staged-file handling.
|
||||||
mode: 0o755,
|
// Stub pnpm too so Windows CI does not invoke a real package-manager command in the temp repo.
|
||||||
});
|
writeExecutable(fakeBinDir, "pnpm", "#!/usr/bin/env bash\nexit 0\n");
|
||||||
|
|
||||||
// Create an untracked file that should NOT be staged by the hook.
|
// Create an untracked file that should NOT be staged by the hook.
|
||||||
writeFileSync(path.join(dir, "secret.txt"), "do-not-stage\n", "utf8");
|
writeFileSync(path.join(dir, "secret.txt"), "do-not-stage\n", "utf8");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user