From 765844055ba0d02262a11114bad5da67e935d8df Mon Sep 17 00:00:00 2001 From: Liam Jones Date: Fri, 19 Nov 2021 05:26:24 -0800 Subject: [PATCH] Add volta support to find-node.sh (#32611) Summary: This PR add [volta](https://volta.sh/) support to find-node.sh for use by `scripts/react-native-xcode.sh`, `scripts/generate-specs.sh`, etc. ## Changelog [iOS] [Added] - add volta support to find-node.sh Pull Request resolved: https://github.com/facebook/react-native/pull/32611 Test Plan: Manually tested with volta installed node (and [relevant change](https://docs.volta.sh/guide/understanding#managing-your-project) added to the project's package.json). Without this patch, the `Bundle React Native code and images` Build Phase fails, with it, it succeeds. Tested with both `curl https://get.volta.sh | bash` installed and `brew install volta`. One check works for both because the `node` shim will always be installed to the same location (and the required environment variable exports are the same also) Wasn't sure if you'd want the package.json change applied to rn-tester? Shouldn't affect people who don't use volta. Shout if you want me to add it to this PR. Reviewed By: cortinico Differential Revision: D32498267 Pulled By: yungsters fbshipit-source-id: 93ee187bd2178bfcd8f9009a1a0668c6f5583aa3 --- scripts/find-node.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/find-node.sh b/scripts/find-node.sh index 84e930a12d..2c7e894dd0 100755 --- a/scripts/find-node.sh +++ b/scripts/find-node.sh @@ -50,3 +50,9 @@ 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