From 322f210e64415ce351f869bbb0f1a41d6212a5ff Mon Sep 17 00:00:00 2001 From: Kyle Corbitt Date: Mon, 21 Mar 2016 06:26:02 -0700 Subject: [PATCH] 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 --- local-cli/generator-utils.js | 2 +- local-cli/generator/index.js | 5 ++++- package.json | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/local-cli/generator-utils.js b/local-cli/generator-utils.js index e44f9f0da..9f58f2e53 100644 --- a/local-cli/generator-utils.js +++ b/local-cli/generator-utils.js @@ -19,7 +19,7 @@ function copyAndReplace(src, dest, replacements) { } else { var content = fs.readFileSync(src, 'utf8'); 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); } diff --git a/local-cli/generator/index.js b/local-cli/generator/index.js index 90f08912a..79a7a1936 100644 --- a/local-cli/generator/index.js +++ b/local-cli/generator/index.js @@ -50,7 +50,10 @@ module.exports = yeoman.generators.NamedBase.extend({ utils.copyAndReplace( this.templatePath('../../../.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( diff --git a/package.json b/package.json index 7e14ab46a..e73aec5d8 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,8 @@ "PATENTS", "README.md", "jestSupport", - ".flowconfig" + ".flowconfig", + "flow" ], "scripts": { "test": "NODE_ENV=test jest",