flowconfig adds flow/ folder
Summary:This change adds the `flow/` folder to the generated `.flowconfig` in new/upgraded projects. The absence of this folder was causing flow bugs to appear in projects consuming react-native that weren't visible in react-native itself. By including the same definition in consuming projects these errors disappear. Fixes https://github.com/facebook/react-native/issues/6428. **Test plan (required)** Tested `react-native upgrade` with this change and ensured that the generated `.flowconfig` works and didn't throw flow errors. Closes https://github.com/facebook/react-native/pull/6430 Differential Revision: D3071701 fb-gh-sync-id: f28f4d8f7e63669386766b6f226144adeda32c85 shipit-source-id: f28f4d8f7e63669386766b6f226144adeda32c85
This commit is contained in:
parent
61483aa15d
commit
322f210e64
|
@ -19,7 +19,7 @@ function copyAndReplace(src, dest, replacements) {
|
||||||
} else {
|
} else {
|
||||||
var content = fs.readFileSync(src, 'utf8');
|
var content = fs.readFileSync(src, 'utf8');
|
||||||
Object.keys(replacements).forEach(function(regex) {
|
Object.keys(replacements).forEach(function(regex) {
|
||||||
content = content.replace(new RegExp(regex, 'g'), replacements[regex]);
|
content = content.replace(new RegExp(regex, 'gm'), replacements[regex]);
|
||||||
});
|
});
|
||||||
fs.writeFileSync(dest, content);
|
fs.writeFileSync(dest, content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,10 @@ module.exports = yeoman.generators.NamedBase.extend({
|
||||||
utils.copyAndReplace(
|
utils.copyAndReplace(
|
||||||
this.templatePath('../../../.flowconfig'),
|
this.templatePath('../../../.flowconfig'),
|
||||||
this.destinationPath('.flowconfig'),
|
this.destinationPath('.flowconfig'),
|
||||||
{ 'Libraries\/react-native\/react-native-interface.js' : 'node_modules/react-native/Libraries/react-native/react-native-interface.js' }
|
{
|
||||||
|
'Libraries\/react-native\/react-native-interface.js' : 'node_modules/react-native/Libraries/react-native/react-native-interface.js',
|
||||||
|
'^flow/$' : 'node_modules/react-native/flow\nflow/'
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.fs.copy(
|
this.fs.copy(
|
||||||
|
|
|
@ -112,7 +112,8 @@
|
||||||
"PATENTS",
|
"PATENTS",
|
||||||
"README.md",
|
"README.md",
|
||||||
"jestSupport",
|
"jestSupport",
|
||||||
".flowconfig"
|
".flowconfig",
|
||||||
|
"flow"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "NODE_ENV=test jest",
|
"test": "NODE_ENV=test jest",
|
||||||
|
|
Loading…
Reference in New Issue