mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-19 23:05:51 +00:00
test: 新增测试代码文件
This commit is contained in:
32
tests/mocks/file-system.ts
Normal file
32
tests/mocks/file-system.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { mkdtemp, rm, writeFile, mkdir } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
export async function createTempDir(
|
||||
prefix = "claude-test-",
|
||||
): Promise<string> {
|
||||
return mkdtemp(join(tmpdir(), prefix));
|
||||
}
|
||||
|
||||
export async function cleanupTempDir(dir: string): Promise<void> {
|
||||
await rm(dir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
export async function writeTempFile(
|
||||
dir: string,
|
||||
name: string,
|
||||
content: string,
|
||||
): Promise<string> {
|
||||
const path = join(dir, name);
|
||||
await writeFile(path, content, "utf-8");
|
||||
return path;
|
||||
}
|
||||
|
||||
export async function createTempSubdir(
|
||||
dir: string,
|
||||
name: string,
|
||||
): Promise<string> {
|
||||
const path = join(dir, name);
|
||||
await mkdir(path, { recursive: true });
|
||||
return path;
|
||||
}
|
||||
Reference in New Issue
Block a user