Skip to content

Commit

Permalink
Replace Yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
grabbou committed Oct 4, 2019
1 parent f85186f commit 5c5d0f4
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions packages/platform-ios/native_modules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,35 @@
#
require 'pathname'

def use_native_modules!(config = nil)
# Since CLI is a React Native dependency, we start looking for its
# executable from React Native `node_modules`.
def get_cli_path()
script = '
const path = require("path");
const rnPath = path.dirname(require.resolve("react-native/package.json"));
console.log(
require.resolve("@react-native-community/cli/build/index.js", {
paths: [rnPath]
})
);
';

Pod::Executable.execute_command("node", ["-e", script], true).strip
end

def use_native_modules!(root = "..", config = nil)
if (!config)
json = []

# @todo: Do not use Yarn here, but find path dynamically
IO.popen("yarn run --silent react-native config") do |data|
while line = data.gets
json << line
# Make sure `react-native config` is ran from the project root
# @todo: deprecate `root` and switch to Yarn once `--silent` flag works
Dir.chdir(root) do
IO.popen("node #{get_cli_path} config") do |data|
while line = data.gets
json << line
end
end
end

Expand Down

0 comments on commit 5c5d0f4

Please sign in to comment.