(rootPath, currentPath, entries)
| 181 | } |
| 182 | |
| 183 | async function visitSnapshot(rootPath, currentPath, entries) { |
| 184 | const directoryEntries = await fs.readdir(currentPath, { withFileTypes: true }); |
| 185 | |
| 186 | for (const entry of directoryEntries) { |
| 187 | const entryPath = path.join(currentPath, entry.name); |
| 188 | const relativeEntryPath = relativePath(rootPath, entryPath); |
| 189 | |
| 190 | if (entry.isDirectory()) { |
| 191 | if (SNAPSHOT_IGNORED_DIRS.has(entry.name)) { |
| 192 | continue; |
| 193 | } |
| 194 | await visitSnapshot(rootPath, entryPath, entries); |
| 195 | continue; |
| 196 | } |
| 197 | |
| 198 | if (!entry.isFile()) { |
| 199 | continue; |
| 200 | } |
| 201 | |
| 202 | const stats = await fs.stat(entryPath); |
| 203 | const isText = isProbablyTextFile(entryPath); |
| 204 | const text = isText ? await readText(entryPath) : null; |
| 205 | |
| 206 | entries.set(relativeEntryPath, { |
| 207 | path: relativeEntryPath, |
| 208 | absolutePath: entryPath, |
| 209 | size: stats.size, |
| 210 | hash: await hashFile(entryPath), |
| 211 | isText, |
| 212 | lineCount: text === null ? null : text.replace(/\r\n/g, "\n").split("\n").length, |
| 213 | }); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | export async function snapshotWorkspace(rootPath) { |
| 218 | const entries = new Map(); |
no test coverage detected