From 39a0891c1015a61bf30a7fed779e44e4fcd28dcd Mon Sep 17 00:00:00 2001 From: Josh Mudge Date: Sat, 24 Nov 2018 22:34:27 -0700 Subject: [PATCH] Add helpful error message if the destination directory is not writeable. Working, but not consistant with AJ's code style. --- install.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) mode change 100644 => 100755 install.sh diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index f85d571..dc2dac2 --- a/install.sh +++ b/install.sh @@ -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" \ No newline at end of file +rm -rf "$my_tmp"