From b05294dd99aec241181beecb43f8675b20e9bdfe Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Mon, 19 Oct 2020 15:27:21 -0700 Subject: [PATCH] Codegen fbsource: filter JS files for all cases, then enable codegen_module=True for react-native-github Summary: The specific file filtering in the CLI only covers the case where the input is a directory. We should filter when files are provided as well. Changelog: [Internal] Reviewed By: hramos Differential Revision: D24399225 fbshipit-source-id: 186e39c157faf90bdd825ec5c5860017d49e9404 --- .../cli/combine/combine-js-to-schema-cli.js | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js b/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js index 30443a09c35..64449287296 100644 --- a/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js +++ b/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js @@ -19,6 +19,19 @@ const path = require('path'); const [outfile, ...fileList] = process.argv.slice(2); +function filterJSFile(file) { + return ( + /^(Native.+|.+NativeComponent)/.test(path.basename(file)) && + // NativeUIManager will be deprecated by Fabric UIManager. + // For now, ignore this spec completely because the types are not fully supported. + !file.endsWith('NativeUIManager.js') && + // NativeSampleTurboModule is for demo purpose. It should be added manually to the + // app for now. + !file.endsWith('NativeSampleTurboModule.js') && + !file.includes('__tests') + ); +} + const allFiles = []; fileList.forEach(file => { if (fs.lstatSync(file).isDirectory()) { @@ -26,19 +39,9 @@ fileList.forEach(file => { .sync(`${file}/**/*.js`, { nodir: true, }) - .filter( - f => - /^(Native.+|.+NativeComponent)/.test(path.basename(f)) && - // NativeUIManager will be deprecated by Fabric UIManager. - // For now, ignore this spec completely because the types are not fully supported. - !f.endsWith('NativeUIManager.js') && - // NativeSampleTurboModule is for demo purpose. It should be added manually to the - // app for now. - !f.endsWith('NativeSampleTurboModule.js') && - !f.includes('__tests'), - ); + .filter(filterJSFile); allFiles.push(...dirFiles); - } else { + } else if (filterJSFile(file)) { allFiles.push(file); } });