Skip to content

Commit 1dbed97

Browse files
authored
fix: use npx to call rnccli (#693)
### Summary Fixes #691 We created a custom way of calling the React Native Community CLI with #685. But it broke the easy workflow with monorepos. We made the original change to be able to call codegen build from XCode actions but since we dropped the support for that, we can revert the change back. This keeps the new file but uses the old method of calling the cil (npx). ### Test plan 1. Create a new project that supports the new architecture 2. Call `yarn prepare` and make sure everything passes.
1 parent cac236d commit 1dbed97

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed
Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { type SpawnOptions } from 'node:child_process';
22
import { spawn } from './spawn';
3-
import path from 'node:path';
4-
import fs from 'fs-extra';
5-
import assert from 'node:assert';
6-
7-
const NODE_BINARY = 'node';
83

94
/**
105
* Runs the React Native Community CLI with the specified arguments
@@ -15,37 +10,5 @@ export async function runRNCCli(
1510
stdio: 'ignore',
1611
}
1712
) {
18-
const rncCliBinaryName = await getCliBinaryName();
19-
20-
const RNC_CLI_BINARY_PATH = path.resolve(
21-
process.cwd(), // We are always expected to run in the library
22-
'node_modules',
23-
'.bin',
24-
rncCliBinaryName
25-
);
26-
27-
return await spawn(RNC_CLI_BINARY_PATH, args, options);
28-
}
29-
30-
async function getCliBinaryName(): Promise<string> {
31-
const rncCliPackagePath = await spawn(NODE_BINARY, [
32-
'-e',
33-
`console.log(require.resolve('@react-native-community/cli/package.json'))`,
34-
]);
35-
36-
const rncCliPackage = await fs.readJson(rncCliPackagePath);
37-
const binProperty = rncCliPackage.bin as Record<string, string>;
38-
assert(
39-
typeof binProperty === 'object',
40-
"React Native CLI doesn't specify proper binaries"
41-
);
42-
43-
const binaries = Object.keys(binProperty);
44-
const rncCliBinaryName = binaries[0] as string;
45-
assert(
46-
typeof rncCliBinaryName === 'string',
47-
"React Native Community CLI doesn't have any binaries to run"
48-
);
49-
50-
return rncCliBinaryName;
13+
return await spawn('npx', ['@react-native-community/cli', ...args], options);
5114
}

0 commit comments

Comments
 (0)