(data: {
removedFiles: FileData;
changedFiles?: FileData;
hasteMap: InternalHasteMap;
})
| 662 | } |
| 663 | |
| 664 | private _buildHasteMap(data: { |
| 665 | removedFiles: FileData; |
| 666 | changedFiles?: FileData; |
| 667 | hasteMap: InternalHasteMap; |
| 668 | }): Promise<InternalHasteMap> { |
| 669 | const {removedFiles, changedFiles, hasteMap} = data; |
| 670 | |
| 671 | // If any files were removed or we did not track what files changed, process |
| 672 | // every file looking for changes. Otherwise, process only changed files. |
| 673 | let map: ModuleMapData; |
| 674 | let mocks: MockData; |
| 675 | let filesToProcess: FileData; |
| 676 | if (changedFiles === undefined || removedFiles.size > 0) { |
| 677 | map = new Map(); |
| 678 | mocks = new Map(); |
| 679 | filesToProcess = hasteMap.files; |
| 680 | } else { |
| 681 | map = hasteMap.map; |
| 682 | mocks = hasteMap.mocks; |
| 683 | filesToProcess = changedFiles; |
| 684 | } |
| 685 | |
| 686 | for (const [relativeFilePath, fileMetadata] of removedFiles) { |
| 687 | this._recoverDuplicates(hasteMap, relativeFilePath, fileMetadata[H.ID]); |
| 688 | } |
| 689 | |
| 690 | const promises: Array<Promise<void>> = []; |
| 691 | for (const relativeFilePath of filesToProcess.keys()) { |
| 692 | if ( |
| 693 | this._options.skipPackageJson && |
| 694 | relativeFilePath.endsWith(PACKAGE_JSON) |
| 695 | ) { |
| 696 | continue; |
| 697 | } |
| 698 | // SHA-1, if requested, should already be present thanks to the crawler. |
| 699 | const filePath = fastPath.resolve( |
| 700 | this._options.rootDir, |
| 701 | relativeFilePath, |
| 702 | ); |
| 703 | const promise = this._processFile(hasteMap, map, mocks, filePath); |
| 704 | if (promise) { |
| 705 | promises.push(promise); |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | return Promise.all(promises).then( |
| 710 | () => { |
| 711 | this._cleanup(); |
| 712 | hasteMap.map = map; |
| 713 | hasteMap.mocks = mocks; |
| 714 | return hasteMap; |
| 715 | }, |
| 716 | error => { |
| 717 | this._cleanup(); |
| 718 | throw error; |
| 719 | }, |
| 720 | ); |
| 721 | } |
no test coverage detected