diff --git a/setup-node-ubuntu.bash b/setup-node-ubuntu.bash index 753ce20..db3210d 100644 --- a/setup-node-ubuntu.bash +++ b/setup-node-ubuntu.bash @@ -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 \ No newline at end of file