From 802b3f778b4d2ecd22882b371a84293421558b8a Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 21 Feb 2022 03:06:07 -0800 Subject: [PATCH] Remove `find-node.sh` script (#33146) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/33146 Pull Request resolved: https://github.com/facebook/react-native/pull/33145 It removes the find node script that introduced complexity in the system. ## Changelog [Internal][Removed] - Removed the old `find-node.sh` script which was only adding complexity without doing nothing really useful. Reviewed By: cortinico Differential Revision: D34352049 fbshipit-source-id: 9ba4275c3863a1ae4bc2b4e2f1694a7ac994cdc8 --- .circleci/config.yml | 6 -- package.json | 1 - scripts/find-node.sh | 69 ------------------- scripts/react-native-xcode.sh | 4 +- .../react_native_pods_utils/script_phases.sh | 2 - 5 files changed, 1 insertion(+), 81 deletions(-) delete mode 100755 scripts/find-node.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 54fb2376a7..90b87795e7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -389,12 +389,6 @@ jobs: - brew_install: package: applesimutils - - run: - name: Configure Node - # Sourcing find-node.sh will ensure nvm is set up. - # It also helps future invocation of find-node.sh prevent permission issue with nvm.sh. - command: source scripts/find-node.sh && nvm install 16 && nvm alias default 16 - - run: name: Configure Watchman command: echo "{}" > .watchmanconfig diff --git a/package.json b/package.json index 4fffa587b9..813603c990 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "README.md", "rn-get-polyfills.js", "scripts/compose-source-maps.js", - "scripts/find-node.sh", "scripts/generate-artifacts.js", "scripts/generate-provider-cli.js", "scripts/generate-specs-cli.js", diff --git a/scripts/find-node.sh b/scripts/find-node.sh deleted file mode 100755 index 11338d0a5d..0000000000 --- a/scripts/find-node.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -set -e - -# remove global prefix if it's already set -# the running shell process will choose a node binary and a global package directory breaks version managers -unset PREFIX - -# Support Homebrew on M1 -HOMEBREW_M1_BIN=/opt/homebrew/bin -if [[ -d $HOMEBREW_M1_BIN && ! $PATH =~ $HOMEBREW_M1_BIN ]]; then - export PATH="$HOMEBREW_M1_BIN:$PATH" -fi - -# Define NVM_DIR and source the nvm.sh setup script -[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm" - -# Source nvm with '--no-use' and then `nvm use` to respect .nvmrc -# See: https://github.com/nvm-sh/nvm/issues/2053 -if [[ -s "$HOME/.nvm/nvm.sh" ]]; then - # shellcheck source=/dev/null - . "$HOME/.nvm/nvm.sh" --no-use - nvm use 2> /dev/null || nvm use default -elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then - # shellcheck source=/dev/null - . "$(brew --prefix nvm)/nvm.sh" --no-use - nvm use 2> /dev/null || nvm use default -fi - -# Set up the nodenv node version manager if present -if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then - eval "$("$HOME/.nodenv/bin/nodenv" init -)" -elif [[ -x "$(command -v brew)" && -x "$(brew --prefix nodenv)/bin/nodenv" ]]; then - eval "$("$(brew --prefix nodenv)/bin/nodenv" init -)" -fi - -# Set up the ndenv of anyenv if preset -if [[ ! -x node && -d ${HOME}/.anyenv/bin ]]; then - export PATH=${HOME}/.anyenv/bin:${PATH} - if [[ "$(anyenv envs | grep -c ndenv )" -eq 1 ]]; then - eval "$(anyenv init -)" - fi -fi - -# Set up asdf-vm if present -if [[ -f "$HOME/.asdf/asdf.sh" ]]; then - # shellcheck source=/dev/null - . "$HOME/.asdf/asdf.sh" -elif [[ -x "$(command -v brew)" && -f "$(brew --prefix asdf)/asdf.sh" ]]; then - # shellcheck source=/dev/null - . "$(brew --prefix asdf)/asdf.sh" -fi - -# Set up volta if present -if [[ -x "$HOME/.volta/bin/node" ]]; then - export VOLTA_HOME="$HOME/.volta" - export PATH="$VOLTA_HOME/bin:$PATH" -fi - -# Set up the fnm node version manager if present -if [[ -x "$HOME/.fnm/fnm" ]]; then - eval "$("$HOME/.fnm/fnm" env)" -elif [[ -x "$(command -v brew)" && -x "$(brew --prefix fnm)/bin/fnm" ]]; then - eval "$("$(brew --prefix fnm)/bin/fnm" env)" -fi diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh index ad31b9c24d..4521b7f7ce 100755 --- a/scripts/react-native-xcode.sh +++ b/scripts/react-native-xcode.sh @@ -79,9 +79,7 @@ if [[ $DEV != true && ! -f "$ENTRY_FILE" ]]; then exit 2 fi -# Find path to Node -# shellcheck source=/dev/null -source "$REACT_NATIVE_DIR/scripts/find-node.sh" +NODE_BINARY="$(command -v node)" # check and assign NODE_BINARY env # shellcheck source=/dev/null diff --git a/scripts/react_native_pods_utils/script_phases.sh b/scripts/react_native_pods_utils/script_phases.sh index 9ae04f017a..7f26218d55 100755 --- a/scripts/react_native_pods_utils/script_phases.sh +++ b/scripts/react_native_pods_utils/script_phases.sh @@ -33,8 +33,6 @@ else fi find_node () { - # shellcheck disable=SC1091 - source "$RCT_SCRIPT_RN_DIR/scripts/find-node.sh" NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}" if [ -z "$NODE_BINARY" ]; then