Compare commits

..

1 Commits

3 changed files with 50 additions and 47 deletions

View File

@ -1,16 +1,6 @@
# STOP
The install method in this repo still has its place, but this is no longer maintained.
**Update**: Use [Webi](https://webinstall.dev) instead:
```sh
curl https://webinstall.dev/node | bash
```
# Easy Install node.js
| A [Root](https://rootprojects.org) Project |
| Sponsored by [ppl](https://ppl.family) |
Simple node.js installer for macOS and Linux

77
install.sh Normal file → Executable file
View File

@ -56,38 +56,37 @@ if [ "$(uname | grep -i 'Darwin')" ]; then
exit 1
fi
# Mavericks+ works for all current macOS versions
OS='mavericks'
if [[ "$OSX_MAJOR" -eq 10 ]]; then
#
# Minor
#
if [ "$OSX_MINOR" -le 5 ]; then
echo "unsupported OS X version (os 10.5-)"
exit 1
fi
# Snow
if [ "$OSX_MINOR" -eq 6 ]; then
OS='snow'
fi
# Lion
if [ $OSX_MINOR -eq 7 ]; then
OS='lion'
fi
# Mountain Lion
if [ "$OSX_MINOR" -eq 8 ]; then
OS='mountain'
fi
if [ "$OSX_MAJOR" -gt 10 ]; then
echo "unsupported OS X version (os 11+)"
exit 1
fi
# OS X (10) and macOS (11) should be supported
#
# Minor
#
if [ "$OSX_MINOR" -le 5 ]; then
echo "unsupported OS X version (os 10.5-)"
exit 1
fi
if [ "$OSX_MAJOR" -gt 11 ]; then
echo "WARNING: macOS 12+ may or may not be supported"
# Snow
if [ "$OSX_MINOR" -eq 6 ]; then
OS='snow'
fi
# Lion
if [ $OSX_MINOR -eq 7 ]; then
OS='lion'
fi
# Mountain Lion
if [ "$OSX_MINOR" -eq 8 ]; then
OS='mountain'
fi
# Mavericks, Yosemite
if [ "$OSX_MINOR" -ge 9 ]; then
OS='mavericks'
fi
if [ -n "$(sysctl hw | grep 64bit | grep ': 1')" ]; then
@ -290,9 +289,23 @@ if [ -z "${NODE_PATH-}" ]; then
# /usr/local/bin/node => /usr/local
node_install_path="$(dirname $(dirname $(type -p node)))"
echo "NODE_PATH is not set. Using existing node install path: '$node_install_path'"
if ! echo "test" > $node_install_path/.test
then
echo "Node install path is not writable. Run: NODE_PATH=$HOME/.local/opt/node/lib/node_modules"
if [ -f "$node_install_path"/.test ]; then
rm "$node_install_path"/.test
fi
fi
else
node_install_path=$PREFIX/usr/local
echo "NODE_PATH is not set. Using default install path '$node_install_path'"
if ! echo "test" > $node_install_path/.test
then
echo "Node install path is not writable. Run: NODE_PATH=$HOME/.local/opt/node/lib/node_modules"
if [ -f "$node_install_path"/.test ]; then
rm "$node_install_path"/.test
fi
fi
fi
else
node_install_path=$(dirname $(dirname $NODE_PATH))
@ -321,8 +334,8 @@ if [ -n "${NODEJS_VER}" ]; then
bash "$my_tmp/${INSTALL_FILE}" "${NODEJS_VER}"
fi
mkdir -p $node_install_path/lib/node_modules 2> /dev/null || $sudo_cmd mkdir -p $node_install_path/lib/node_modules
chown -R $(whoami) $node_install_path/lib/node_modules 2> /dev/null || $sudo_cmd chown -R $(whoami) $node_install_path/lib/node_modules
mkdir -p $node_install_path/lib/node_modules || $sudo_cmd mkdir -p $node_install_path/lib/node_modules
chown -R $(whoami) $node_install_path/lib/node_modules || $sudo_cmd chown -R $(whoami) $node_install_path/lib/node_modules
echo ""
@ -384,4 +397,4 @@ if [ "--dev-deps" == "$deps_flag" ]; then
echo ""
fi
rm -rf "$my_tmp"
rm -rf "$my_tmp"

View File

@ -73,15 +73,15 @@ if [ -n "${NODEJS_VER}" ]; then
rm ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
echo $sudo_cmd rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/"
rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/" 2>/dev/null || $sudo_cmd rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/"
rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/" || $sudo_cmd rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/"
else
# due to symlink issues on Arch Linux, don't copy the share directory
rm -rf ${NODEJS_UNTAR}/share
echo $sudo_cmd cp -Hr "${NODEJS_UNTAR}/*" "$node_install_path/"
cp -Hr "${NODEJS_UNTAR}"/* "$node_install_path/" 2>/dev/null || $sudo_cmd cp -Hr "${NODEJS_UNTAR}"/* "$node_install_path/"
cp -Hr "${NODEJS_UNTAR}"/* "$node_install_path/" || $sudo_cmd cp -Hr "${NODEJS_UNTAR}"/* "$node_install_path/"
fi
rm -rf "${NODEJS_UNTAR}"
chown -R $(whoami) "$node_install_path/lib/node_modules/" 2>/dev/null || $sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/"
chown $(whoami) ""$node_install_path"/bin/" 2>/dev/null || $sudo_cmd chown $(whoami) ""$node_install_path"/bin/"
chown -R $(whoami) "$node_install_path/lib/node_modules/" || $sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/"
chown $(whoami) ""$node_install_path"/bin/" || $sudo_cmd chown $(whoami) ""$node_install_path"/bin/"
fi