Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/platform-android/native_modules.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class ReactNativeModules {
*
* @todo: `fastlane` has been reported to not work too.
*/
def cliResolveScript = "console.log(require('@react-native-community/cli').bin);"
def cliResolveScript = "console.log(require('react-native/cli').bin);"
String[] nodeCommand = ["node", "-e", cliResolveScript]
def cliPath = this.getCommandOutput(nodeCommand)

Expand Down
3 changes: 2 additions & 1 deletion packages/platform-ios/native_modules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def use_native_modules!(config = nil)
config = nil;
end

cli_resolve_script = "console.log(require('@react-native-community/cli').bin);"
# Resolving the path the RN CLI. The `@react-native-community/cli` module may not be there for certain package managers, so we fall back to resolving it through `react-native` package, that's always present in RN projects
cli_resolve_script = "try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @alloy in reality this try/catch is only necessary for testing environment. Do you think it's better to leave this or somehow detect we're in "test" environment and change path accordingly? (usually a bad idea in my experience)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to mock execute_command instead?

cli_bin = Pod::Executable.execute_command("node", ["-e", cli_resolve_script], true).strip

if (!config)
Expand Down