Add helpful error message if the destination directory is not writeable. Working, but not consistant with AJ's code style.

This commit is contained in:
Josh Mudge 2018-11-24 22:34:27 -07:00
parent 895dcd31f2
commit 39a0891c10
1 changed files with 15 additions and 1 deletions

16
install.sh Normal file → Executable file
View File

@ -289,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))
@ -383,4 +397,4 @@ if [ "--dev-deps" == "$deps_flag" ]; then
echo ""
fi
rm -rf "$my_tmp"
rm -rf "$my_tmp"