浏览代码

Test nodejs version numbers

Bob Mottram 7 年前
父节点
当前提交
1f702d1900
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22
    0
      src/freedombone-utils-nodejs

+ 22
- 0
src/freedombone-utils-nodejs 查看文件

@@ -127,6 +127,28 @@ function mesh_install_nodejs {
127 127
     $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save
128 128
     $mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION}
129 129
     cp $rootdir/root/npm $rootdir/usr/bin/npm
130
+
131
+    # check the version numbers
132
+    cat <<EOF > $rootdir/usr/bin/test_nodejs_install
133
+#!/bin/bash
134
+node_version=\$(node -v)
135
+if [[ "\$node_version" != "v${NODEJS_VERSION}" ]]; then
136
+    echo $"nodejs version expected to be ${NODEJS_VERSION} but found \$node_version"
137
+    exit 1
138
+fi
139
+npm_version=\$(npm -v)
140
+if [[ "\$npm_version" != "v${NPM_VERSION}" ]]; then
141
+    echo $"npm version expected to be ${NPM_VERSION} but found \$npm_version"
142
+    exit 2
143
+fi
144
+EOF
145
+    chmod +x $rootdir/usr/bin/test_nodejs_install
146
+    chroot "$rootdir" /usr/bin/test_nodejs_install
147
+    if [ ! "$?" = "0" ]; then
148
+        echo $"nodejs version numbers did not match. Architecture is $NPM_ARCH."
149
+        exit 76835282
150
+    fi
151
+    rm $rootdir/usr/bin/test_nodejs_install
130 152
 }
131 153
 
132 154
 function remove_nodejs {