Skip to content

Commit f904ece

Browse files
committed
extract getArchitecture function
1 parent 3930008 commit f904ece

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

packages/cli-doctor/src/commands/info.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import getEnvironmentInfo from '../tools/envinfo';
99
import {logger, version} from '@react-native-community/cli-tools';
1010
import {Config} from '@react-native-community/cli-types';
11+
import {getArchitecture} from '@react-native-community/cli-platform-ios';
1112
import {readFile} from 'fs-extra';
1213
import path from 'path';
1314
import {stringify} from 'yaml';
@@ -52,16 +53,11 @@ const info = async function getInfo(_argv: Array<string>, ctx: Config) {
5253
}
5354

5455
try {
55-
const project = await readFile(
56-
path.join(
57-
ctx.project.ios.sourceDir,
58-
'/Pods/Pods.xcodeproj/project.pbxproj',
59-
),
56+
const isNewArchitecture = await getArchitecture(
57+
ctx.project.ios.sourceDir,
6058
);
6159

62-
platforms.iOS.newArchEnabled = project.includes(
63-
'-DRCT_NEW_ARCH_ENABLED=1',
64-
);
60+
platforms.iOS.newArchEnabled = isNewArchitecture;
6561
} catch {
6662
platforms.iOS.newArchEnabled = notFound;
6763
}

packages/cli-platform-ios/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
export {default as commands} from './commands';
66
export {projectConfig, dependencyConfig, findPodfilePaths} from './config';
7+
export {default as getArchitecture} from './tools/getArchitecture';
78
export {default as installPods} from './tools/installPods';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {readFile} from 'fs-extra';
2+
import path from 'path';
3+
4+
export default async function getArchitecture(iosSourceDir: string) {
5+
try {
6+
const project = await readFile(
7+
path.join(iosSourceDir, '/Pods/Pods.xcodeproj/project.pbxproj'),
8+
);
9+
10+
return project.includes('-DRCT_NEW_ARCH_ENABLED=1');
11+
} catch {
12+
return false;
13+
}
14+
}

0 commit comments

Comments
 (0)