(options: CrawlerOptions)
| 193 | } |
| 194 | |
| 195 | export async function nodeCrawl(options: CrawlerOptions): Promise<{ |
| 196 | removedFiles: FileData; |
| 197 | hasteMap: InternalHasteMap; |
| 198 | }> { |
| 199 | const { |
| 200 | data, |
| 201 | extensions, |
| 202 | forceNodeFilesystemAPI, |
| 203 | ignore, |
| 204 | rootDir, |
| 205 | enableSymlinks, |
| 206 | roots, |
| 207 | } = options; |
| 208 | |
| 209 | const useNativeFind = await hasNativeFindSupport(forceNodeFilesystemAPI); |
| 210 | |
| 211 | return new Promise(resolve => { |
| 212 | const callback = (list: Result) => { |
| 213 | const files = new Map(); |
| 214 | const removedFiles = new Map(data.files); |
| 215 | for (const fileData of list) { |
| 216 | const [filePath, mtime, size] = fileData; |
| 217 | const relativeFilePath = fastPath.relative(rootDir, filePath); |
| 218 | const existingFile = data.files.get(relativeFilePath); |
| 219 | if (existingFile && existingFile[H.MTIME] === mtime) { |
| 220 | files.set(relativeFilePath, existingFile); |
| 221 | } else { |
| 222 | // See ../constants.js; SHA-1 will always be null and fulfilled later. |
| 223 | files.set(relativeFilePath, ['', mtime, size, 0, '', null]); |
| 224 | } |
| 225 | removedFiles.delete(relativeFilePath); |
| 226 | } |
| 227 | data.files = files; |
| 228 | |
| 229 | resolve({ |
| 230 | hasteMap: data, |
| 231 | removedFiles, |
| 232 | }); |
| 233 | }; |
| 234 | |
| 235 | if (useNativeFind) { |
| 236 | findNative(roots, extensions, ignore, enableSymlinks, callback); |
| 237 | } else { |
| 238 | find(roots, extensions, ignore, enableSymlinks, callback); |
| 239 | } |
| 240 | }); |
| 241 | } |
no test coverage detected