From 68f94f498ee98c66f85a655ba529e6289d53a80d Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Fri, 30 Mar 2018 14:15:04 +0100 Subject: [PATCH] Handle image install of global node modules directory --- src/freedombone-utils-nodejs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/freedombone-utils-nodejs b/src/freedombone-utils-nodejs index 3068b2bc7..29a872fd4 100755 --- a/src/freedombone-utils-nodejs +++ b/src/freedombone-utils-nodejs @@ -204,18 +204,20 @@ function nodejs_upgrade { } function nodejs_setup_global_modules { - if [ ! -d /root/.npm-global ]; then - mkdir /root/.npm-global + if [ ! -d "$rootdir/root/.npm-global" ]; then + mkdir "$rootdir/root/.npm-global" fi - npm config set prefix '/root/.npm-global' - export PATH=/root/.npm-global/bin:$PATH - if ! grep -q "PATH=/root/.npm-global/bin" /root/.bashrc; then - echo "PATH=/root/.npm-global/bin:\$PATH" >> /root/.bashrc + $mesh_install_nodejs_prefix npm config set prefix '/root/.npm-global' + if ! grep -q "PATH=/root/.npm-global/bin" "$rootdir/root/.bashrc"; then + echo "PATH=/root/.npm-global/bin:\$PATH" >> "$rootdir/root/.bashrc" fi - if ! grep -q "NPM_CONFIG_PREFIX=" /root/.bashrc; then - echo "export NPM_CONFIG_PREFIX=/root/.npm-global" >> /root/.bashrc + if ! grep -q "NPM_CONFIG_PREFIX=" "$rootdir/root/.bashrc"; then + echo "export NPM_CONFIG_PREFIX=/root/.npm-global" >> "$rootdir/root/.bashrc" + fi + if [ ! "$rootdir" ]; then + export PATH=/root/.npm-global/bin:$PATH + export NPM_CONFIG_PREFIX=/root/.npm-global fi - export NPM_CONFIG_PREFIX=/root/.npm-global } function remove_nodejs { -- GitLab