(
type: string,
filePath: string,
root: string,
stat?: Stats,
)
| 873 | }; |
| 874 | |
| 875 | const onChange = ( |
| 876 | type: string, |
| 877 | filePath: string, |
| 878 | root: string, |
| 879 | stat?: Stats, |
| 880 | ) => { |
| 881 | filePath = path.join(root, normalizePathSep(filePath)); |
| 882 | if ( |
| 883 | (stat && stat.isDirectory()) || |
| 884 | this._ignore(filePath) || |
| 885 | !extensions.some(extension => filePath.endsWith(extension)) |
| 886 | ) { |
| 887 | return; |
| 888 | } |
| 889 | |
| 890 | const relativeFilePath = fastPath.relative(rootDir, filePath); |
| 891 | const fileMetadata = hasteMap.files.get(relativeFilePath); |
| 892 | |
| 893 | // The file has been accessed, not modified |
| 894 | if ( |
| 895 | type === 'change' && |
| 896 | fileMetadata && |
| 897 | stat && |
| 898 | fileMetadata[H.MTIME] === stat.mtime.getTime() |
| 899 | ) { |
| 900 | return; |
| 901 | } |
| 902 | |
| 903 | changeQueue = changeQueue |
| 904 | .then(() => { |
| 905 | // If we get duplicate events for the same file, ignore them. |
| 906 | if ( |
| 907 | eventsQueue.some( |
| 908 | event => |
| 909 | event.type === type && |
| 910 | event.filePath === filePath && |
| 911 | ((!event.stat && !stat) || |
| 912 | (!!event.stat && |
| 913 | !!stat && |
| 914 | event.stat.mtime.getTime() === stat.mtime.getTime())), |
| 915 | ) |
| 916 | ) { |
| 917 | return null; |
| 918 | } |
| 919 | |
| 920 | if (mustCopy) { |
| 921 | mustCopy = false; |
| 922 | hasteMap = { |
| 923 | clocks: new Map(hasteMap.clocks), |
| 924 | duplicates: new Map(hasteMap.duplicates), |
| 925 | files: new Map(hasteMap.files), |
| 926 | map: new Map(hasteMap.map), |
| 927 | mocks: new Map(hasteMap.mocks), |
| 928 | }; |
| 929 | } |
| 930 | |
| 931 | const add = () => { |
| 932 | eventsQueue.push({filePath, stat, type}); |
nothing calls this directly
no test coverage detected