summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-12-20 09:00:04 +0100
committerGitHub <[email protected]>2021-12-20 09:00:04 +0100
commit024c8111337105e7ca624aa71c9adb2f0718a15f (patch)
tree33a1373a2895c69786654e96d446f7c631411837 /utils
parentf1ca79e628090d10c46cccdb6387f13b696c70cf (diff)
fix(installer): check if npm-prefix is writable (#2091)
Diffstat (limited to 'utils')
-rwxr-xr-xutils/installer/install.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/utils/installer/install.sh b/utils/installer/install.sh
index 61519998..1dc77513 100755
--- a/utils/installer/install.sh
+++ b/utils/installer/install.sh
@@ -210,6 +210,7 @@ function __install_nodejs_deps_npm() {
npm install -g "$dep"
fi
done
+
echo "All NodeJS dependencies are successfully installed"
}
@@ -219,10 +220,22 @@ function __install_nodejs_deps_yarn() {
echo "All NodeJS dependencies are successfully installed"
}
+function __validate_node_installation() {
+ local pkg_manager="$1"
+ local manager_home
+ manager_home="$($pkg_manager config get prefix 2>/dev/null)"
+
+ if [ ! -d "$manager_home" ] || [ ! -w "$manager_home" ]; then
+ echo "[ERROR] Unable to install without administrative privilages. Please set you NPM_HOME correctly and try again."
+ exit 1
+ fi
+}
+
function install_nodejs_deps() {
local -a pkg_managers=("yarn" "npm")
for pkg_manager in "${pkg_managers[@]}"; do
if command -v "$pkg_manager" &>/dev/null; then
+ __validate_node_installation "$pkg_manager"
eval "__install_nodejs_deps_$pkg_manager"
return
fi