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

Invoke node directly in generate-specs.sh #30781

Closed
wants to merge 3 commits into from
Closed
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
18 changes: 10 additions & 8 deletions scripts/generate-specs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set -e
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
TEMP_DIR=$(mktemp -d /tmp/react-native-codegen-XXXXXXXX)
RN_DIR=$(cd "$THIS_DIR/.." && pwd)
YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}"
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
USE_FABRIC="${USE_FABRIC:-0}"

cleanup () {
Expand Down Expand Up @@ -64,21 +64,23 @@ main() {
echo "Error: Could not determine react-native-codegen location. Try running 'yarn install' or 'npm install' in your project root." 1>&2
exit 1
fi

if [ ! -d "$CODEGEN_PATH/lib" ]; then
describe "Building react-native-codegen package"
pushd "$CODEGEN_PATH" >/dev/null || exit
"$YARN_BINARY"
"$YARN_BINARY" build
popd >/dev/null || exit
bash "$CODEGEN_PATH/scripts/oss/build.sh"
fi

if [ -z "$NODE_BINARY" ]; then
echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
exit 1
fi

describe "Generating schema from flow types"
"$YARN_BINARY" node "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR"
"$NODE_BINARY" "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR"

describe "Generating native code from schema (iOS)"
pushd "$RN_DIR" >/dev/null || exit
"$YARN_BINARY" --silent node scripts/generate-specs-cli.js ios "$SCHEMA_FILE" "$TEMP_OUTPUT_DIR" "$CODEGEN_MODULES_LIBRARY_NAME"
"$NODE_BINARY" scripts/generate-specs-cli.js ios "$SCHEMA_FILE" "$TEMP_OUTPUT_DIR" "$CODEGEN_MODULES_LIBRARY_NAME"
popd >/dev/null || exit

mkdir -p "$CODEGEN_COMPONENTS_OUTPUT_DIR" "$CODEGEN_MODULES_OUTPUT_DIR"
Expand Down