From c7895df09538c85622abf8413824ed6a645e63e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 14 Feb 2020 12:37:57 +0100 Subject: [PATCH 1/2] fix: resolve CLI through react-native to avoid hoisting issues --- packages/platform-android/native_modules.gradle | 2 +- packages/platform-ios/native_modules.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/platform-android/native_modules.gradle b/packages/platform-android/native_modules.gradle index d6fca9ff5..8f5dc4007 100644 --- a/packages/platform-android/native_modules.gradle +++ b/packages/platform-android/native_modules.gradle @@ -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) diff --git a/packages/platform-ios/native_modules.rb b/packages/platform-ios/native_modules.rb index ed56e7523..484ffbf78 100644 --- a/packages/platform-ios/native_modules.rb +++ b/packages/platform-ios/native_modules.rb @@ -15,7 +15,7 @@ def use_native_modules!(config = nil) config = nil; end - cli_resolve_script = "console.log(require('@react-native-community/cli').bin);" + cli_resolve_script = "console.log(require('react-native/cli').bin);" cli_bin = Pod::Executable.execute_command("node", ["-e", cli_resolve_script], true).strip if (!config) From 5b0449562fb5e56a0b2f96cb1cd265f93bc781e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 14 Feb 2020 12:54:30 +0100 Subject: [PATCH 2/2] fix tests --- packages/platform-ios/native_modules.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/platform-ios/native_modules.rb b/packages/platform-ios/native_modules.rb index 484ffbf78..5617bb146 100644 --- a/packages/platform-ios/native_modules.rb +++ b/packages/platform-ios/native_modules.rb @@ -15,7 +15,8 @@ def use_native_modules!(config = nil) config = nil; end - cli_resolve_script = "console.log(require('react-native/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);}" cli_bin = Pod::Executable.execute_command("node", ["-e", cli_resolve_script], true).strip if (!config)