























@@ -1,11 +1,13 @@
11import { execFileSync } from "node:child_process";
2-import { mkdirSync, writeFileSync } from "node:fs";
2+import { cpSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3+import { tmpdir } from "node:os";
34import path from "node:path";
4-import { describe, expect, it } from "vitest";
5+import { afterAll, beforeAll, describe, expect, it } from "vitest";
56import { createScriptTestHarness } from "./test-helpers.js";
6778const scriptPath = path.join(process.cwd(), "scripts", "committer");
89const { createTempDir } = createScriptTestHarness();
10+let templateRepo: string;
9111012function run(cwd: string, command: string, args: string[]) {
1113return execFileSync(command, args, {
@@ -20,7 +22,12 @@ function git(cwd: string, ...args: string[]) {
20222123function createRepo() {
2224const repo = createTempDir("committer-test-");
25+cpSync(templateRepo, repo, { recursive: true });
26+return repo;
27+}
232829+function createTemplateRepo() {
30+const repo = mkdtempSync(path.join(tmpdir(), "committer-template-"));
2431git(repo, "init", "-q");
2532git(repo, "config", "user.email", "test@example.com");
2633git(repo, "config", "user.name", "Test User");
@@ -71,6 +78,14 @@ function committedFileContents(repo: string, relativePath: string) {
7178}
72797380describe("scripts/committer", () => {
81+beforeAll(() => {
82+templateRepo = createTemplateRepo();
83+});
84+85+afterAll(() => {
86+rmSync(templateRepo, { recursive: true, force: true });
87+});
88+7489it("accepts supported path argument shapes", () => {
7590const cases = [
7691{
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。