in packages/flow-upgrade/src/findFlowFiles.js [69:112]
function processFilePath(directory: string, fileName: string) {
// If we were rejected then we should not continue.
if (rejected === true) {
return;
}
// We are now waiting on this asynchronous task.
waiting++;
// Get the file file path for this file.
const filePath = path.join(directory, fileName);
// Get the stats for the file.
fs.lstat(filePath, (error, stats) => {
if (error) {
return reject(error);
}
// If this is a directory...
if (stats.isDirectory()) {
// ...and it is not an ignored directory...
if (
fileName !== 'node_modules' &&
fileName !== 'flow-typed' &&
fileName !== '__flowtests__'
) {
// ...then recursively process the directory.
processDirectory(filePath);
}
} else if (stats.isFile()) {
// Otherwise if this is a JavaScript/JSX file and it is not an ignored
// JavaScript file...
const fileIsJsOrJsx = /\.jsx?$/.test(fileName);
const fileIsIgnored = fileName.endsWith('-flowtest.js');
if (fileIsJsOrJsx && !fileIsIgnored) {
// Then process the file path as JavaScript.
processJavaScriptFilePath(filePath, stats.size);
}
// If this is a Flow file then we don't need to check the file pragma
// and can add the file to our paths immediately.
if (fileName.endsWith('.flow')) {
filePaths.push(filePath);
}
}
// We are done with this async task
done();
});
}