Update setup-node-ubuntu.bash to use portable `$sudo_cmd` syntax

This commit is contained in:
richdex14 2017-09-04 12:20:00 -06:00
parent a24f92df98
commit 2f9f3c0c82
1 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,9 @@
#!/bin/bash
# Not every platform has or needs sudo, gotta save them O(1)s...
sudo_cmd=""
((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo"
set -e
set -u
set -o pipefail
@ -66,9 +70,9 @@ if [ -n "${NODEJS_VER}" ]; then
rm ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
echo "$node_install_path"
echo "${NODEJS_UNTAR}"
sudo rsync -av "${NODEJS_UNTAR}/" "$node_install_path/"
$sudo_cmd rsync -av "${NODEJS_UNTAR}/" "$node_install_path/"
echo "Done copying"
sudo chown -R $(whoami) "$node_install_path/lib/node_modules/"
sudo chown $(whoami) ""$node_install_path"/bin/"
$sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/"
$sudo_cmd chown $(whoami) ""$node_install_path"/bin/"
fi