(root: string)
| 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 |
no test coverage detected