Skip to content

Commit 4b68734

Browse files
committedMar 1, 2021
Generalize node search logic
1 parent 7159bcb commit 4b68734

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
 

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"scripts/packager.sh",
4747
"scripts/react_native_pods.rb",
4848
"scripts/react-native-xcode.sh",
49+
"scripts/find-node.sh",
4950
"template.config.js",
5051
"template",
5152
"third-party-podspecs"

‎scripts/find-node.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Copyright (c) Facebook, Inc. and its affiliates.
3+
#
4+
# This source code is licensed under the MIT license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
set -e
8+
9+
# Define NVM_DIR and source the nvm.sh setup script
10+
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
11+
12+
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
13+
. "$HOME/.nvm/nvm.sh"
14+
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
15+
. "$(brew --prefix nvm)/nvm.sh"
16+
fi
17+
18+
# Set up the nodenv node version manager if present
19+
if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
20+
eval "$("$HOME/.nodenv/bin/nodenv" init -)"
21+
elif [[ -x "$(command -v brew)" && -x "$(brew --prefix nodenv)/bin/nodenv" ]]; then
22+
eval "$("$(brew --prefix nodenv)/bin/nodenv" init -)"
23+
fi
24+
25+
# Set up the ndenv of anyenv if preset
26+
if [[ ! -x node && -d ${HOME}/.anyenv/bin ]]; then
27+
export PATH=${HOME}/.anyenv/bin:${PATH}
28+
if [[ "$(anyenv envs | grep -c ndenv )" -eq 1 ]]; then
29+
eval "$(anyenv init -)"
30+
fi
31+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.