Skip to content

Commit 503383f

Browse files
committed
perf: use codegen config to find component descriptors
1 parent d1e8f1a commit 503383f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎packages/cli-config-android/src/config/findComponentDescriptors.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ import {extractComponentDescriptors} from './extractComponentDescriptors';
55
import {unixifyPaths} from '@react-native-community/cli-tools';
66

77
export function findComponentDescriptors(packageRoot: string) {
8-
const files = glob.sync('**/+(*.js|*.jsx|*.ts|*.tsx)', {
8+
let jsSrcsDir = null;
9+
try {
10+
const packageJson = fs.readFileSync(
11+
path.join(packageRoot, 'package.json'),
12+
'utf8',
13+
);
14+
jsSrcsDir = JSON.parse(packageJson).codegenConfig.jsSrcsDir;
15+
} catch (error) {
16+
// no jsSrcsDir, continue with default glob pattern
17+
}
18+
const globPattern = jsSrcsDir
19+
? `${jsSrcsDir}/**/+(*.js|*.jsx|*.ts|*.tsx)`
20+
: '**/+(*.js|*.jsx|*.ts|*.tsx)';
21+
const files = glob.sync(globPattern, {
922
cwd: unixifyPaths(packageRoot),
1023
onlyFiles: true,
1124
ignore: ['**/node_modules/**'],

0 commit comments

Comments
 (0)