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
14 changes: 11 additions & 3 deletions packages/platform-android/native_modules.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class ReactNativeModules {
private ArrayList<HashMap<String, String>> reactNativeModules

private static String LOG_PREFIX = ":ReactNative:"
private static String REACT_NATIVE_CLI_BIN = "node_modules${File.separator}@react-native-community${File.separator}cli${File.separator}build${File.separator}index.js"
private static String REACT_NATIVE_CONFIG_CMD = "node ${REACT_NATIVE_CLI_BIN} config"
private static String REACT_NATIVE_CONFIG_CMD = "yarn run --silent react-native config"
private static String REACT_NATIVE_CONFIG_CMD_FALLBACK = "node ./node_modules/.bin/react-native config"

ReactNativeModules(Logger logger) {
this.logger = logger
Expand Down Expand Up @@ -173,9 +173,17 @@ class ReactNativeModules {
ArrayList<HashMap<String, String>> reactNativeModules = new ArrayList<HashMap<String, String>>()

def cmdProcess
def root = getReactNativeProjectRoot()
def command = REACT_NATIVE_CONFIG_CMD_FALLBACK

try {
cmdProcess = Runtime.getRuntime().exec(REACT_NATIVE_CONFIG_CMD, null, getReactNativeProjectRoot())
try {
// Check if project uses Yarn
def isYarnProject = Runtime.getRuntime().exec("node -e console.log(require.resolve('./yarn.lock'))", null, root)
isYarnProject.waitFor()
command = REACT_NATIVE_CONFIG_CMD
} catch(Exception exception) {}
cmdProcess = Runtime.getRuntime().exec(command, null, root)
cmdProcess.waitFor()
} catch (Exception exception) {
this.logger.warn("${LOG_PREFIX}${exception.message}")
Expand Down
14 changes: 11 additions & 3 deletions packages/platform-ios/native_modules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
#
def use_native_modules!(root = "..", packages = nil)
if (!packages)
# Resolve the CLI's main index file
cli_bin = Pod::Executable.execute_command("node", ["-e", "console.log(require.resolve('@react-native-community/cli/build/index.js'))"], true).strip
command = "node"
args = ["./node_modules/.bin/react-native", "config"]
begin
# Check if project uses Yarn
Pod::Executable.execute_command("node", ["-e", "console.log(require.resolve('#{root}/yarn.lock'))"], true)
command = "yarn"
args = ["run", "--silent", "react-native", "config"]
rescue
end

output = ""
# Make sure `react-native config` is ran from your project root
Dir.chdir(root) do
output = Pod::Executable.execute_command("node", [cli_bin, "config"], true)
output = Pod::Executable.execute_command(command, args, true)
end

json = []
Expand Down