-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use node to call rnccli codegen
- Loading branch information
Showing
2 changed files
with
30 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { type SpawnOptions } from 'node:child_process'; | ||
import { spawn } from './spawn'; | ||
import path from 'node:path'; | ||
|
||
const RNC_CLI_BINARY_PATH = path.resolve( | ||
process.cwd(), // We are always expected to run in the library | ||
'node_modules', | ||
'.bin', | ||
'rnc-cli' | ||
); | ||
|
||
// This is a special case for calling bob from the XCode scripts | ||
// XCode scripts don't have the node binary properly set | ||
// We expose an env value for node instead. | ||
const NODE_BINARY = process.env['NODE_BINARY'] || 'node'; | ||
|
||
/** | ||
* Runs the React Native Community CLI with the specified arguments | ||
*/ | ||
export async function runRNCCli( | ||
args: string[], | ||
options: SpawnOptions = { | ||
stdio: 'ignore', | ||
} | ||
) { | ||
return await spawn(NODE_BINARY, [RNC_CLI_BINARY_PATH, ...args], options); | ||
} |