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

Function snapshotDirectory

test/commands/legacy-groups-removed.test.ts:30–49  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

28 });
29
30 function snapshotDirectory(root: string): Map<string, string> {
31 const snapshot = new Map<string, string>();
32
33 function walk(dir: string): void {
34 for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
35 const fullPath = path.join(dir, entry.name);
36 if (entry.isDirectory()) {
37 // Record directories too, so a command deleting an empty
38 // subdirectory cannot pass the byte-identity check.
39 snapshot.set(`${path.relative(root, fullPath).split(path.sep).join('/')}/`, '');
40 walk(fullPath);
41 } else if (entry.isFile()) {
42 snapshot.set(path.relative(root, fullPath).split(path.sep).join('/'), fs.readFileSync(fullPath, 'utf-8'));
43 }
44 }
45 }
46
47 walk(root);
48 return snapshot;
49 }
50
51 // Frozen legacy bytes, written by the now-deleted workspace commands.
52 // Deliberately NOT the production writer: the pin is that pre-existing

Callers 1

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected