From c770026d472e481925e8df8e0f750d4dde0c7bf5 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Fri, 13 Oct 2017 17:56:59 +0100
Subject: [PATCH] Improve handling of npm install script

---
 src/freedombone-utils-nodejs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/freedombone-utils-nodejs b/src/freedombone-utils-nodejs
index 37b23e2c1..6b1e4fe76 100755
--- a/src/freedombone-utils-nodejs
+++ b/src/freedombone-utils-nodejs
@@ -85,13 +85,17 @@ function mesh_install_nodejs {
         exit 7235728
     fi
 
-    wget https://www.npmjs.com/install.sh -O $rootdir/root/npm_install.sh
+    $mesh_install_nodejs_prefix wget https://www.npmjs.com/install.sh -O /root/npm_install.sh
     if [ ! -f $rootdir/root/npm_install.sh ]; then
         echo $'Unable to download npm installer'
         exit 8793636
     fi
+    if ! grep -q "t=\"\${npm_install}\"" $rootdir/root/npm_install.sh; then
+        echo $'Unable to set npm version within npm_install.sh'
+        exit 629052
+    fi
     $mesh_install_nodejs_prefix chmod +x /root/npm_install.sh
-    sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" $rootdir/root/npm_install.sh
+    $mesh_install_nodejs_prefix sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" /root/npm_install.sh
     $mesh_install_nodejs_prefix /root/npm_install.sh
 
     if [ ! -f $rootdir/usr/bin/npm ]; then
-- 
GitLab