MCPcopy
hub / github.com/Fission-AI/OpenSpec / snapshotDirectory

Function snapshotDirectory

test/cli-e2e/store-lifecycle.test.ts:62–81  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

60}
61
62async function snapshotDirectory(root: string): Promise<Map<string, string>> {
63 const snapshot = new Map<string, string>();
64
65 async function walk(current: string): Promise<void> {
66 const entries = await fs.readdir(current, { withFileTypes: true });
67 for (const entry of entries) {
68 const absolute = path.join(current, entry.name);
69 const relative = path.relative(root, absolute).split(path.sep).join('/');
70 if (entry.isDirectory()) {
71 snapshot.set(`${relative}/`, '');
72 await walk(absolute);
73 } else {
74 snapshot.set(relative, await fs.readFile(absolute, 'utf-8'));
75 }
76 }
77 }
78
79 await walk(root);
80 return snapshot;
81}
82
83async function listRelativeEntries(root: string, skipDirs: Set<string>): Promise<string[]> {
84 const found: string[] = [];

Callers 1

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected