Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react_native_pods.rb] Introduce a reusable resolve_node_module function #41990

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 9 additions & 10 deletions packages/react-native/scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@

$START_TIME = Time.now.to_i

# `@react-native-community/cli-platform-ios/native_modules` defines
# use_native_modules. We use node to resolve its path to allow for
# different packager and workspace setups. This is reliant on
# `@react-native-community/cli-platform-ios` being a direct dependency
# of `react-native`.
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
"@react-native-community/cli-platform-ios/native_modules.rb",
{paths: [process.argv[1]]},
)', __dir__]).strip
# This function resolves a path using the node_modules resolution algorithm
# Using this will allow for different packager and workspace setups.
def resolve_node_module(request, from)
code = "require.resolve(process.argv[1], { paths: [process.argv[2]] })"
return Pod::Executable.execute_command('node', ['-p', code, request, from], true).strip
end

# `@react-native-community/cli-platform-ios/native_modules` defines use_native_modules.
# This is reliant on `@react-native-community/cli-platform-ios` being a direct dependency of `react-native`.
require resolve_node_module("@react-native-community/cli-platform-ios/native_modules.rb", __dir__)

def min_ios_version_supported
return Helpers::Constants.min_ios_version_supported
Expand Down
Loading