aboutsummaryrefslogtreecommitdiffstats
path: root/checknodeversion.sh
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
committerterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
commit6e528248414e330c9e25e81596ab47b8b8a5b701 (patch)
treee1aa41a7f3198eeac187e6177ec7d4a33db229d3 /checknodeversion.sh
downloadscripts-6e528248414e330c9e25e81596ab47b8b8a5b701.tar.gz
scripts-6e528248414e330c9e25e81596ab47b8b8a5b701.zip
first commitmaster
Diffstat (limited to 'checknodeversion.sh')
-rwxr-xr-xchecknodeversion.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/checknodeversion.sh b/checknodeversion.sh
new file mode 100755
index 0000000..9f13e80
--- /dev/null
+++ b/checknodeversion.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+function check_node_version() {
+ MIN_VERSION="7.6.0"
+ if [[ "$MIN_VERSION" == "$1" ]]; then return 0;fi
+ local IFS=.
+ VERSION="${1:1}"
+ local i ver1=($MIN_VERSION) ver2=($VERSION)
+ for ((i=0; i < ${#ver1[@]}; i++)); do
+ if [[ 10#${ver1[i]} > 10#${ver2[i]} ]]; then return 1;fi
+ if [[ 10#${ver1[i]} < 10#${ver2[i]} ]]; then return 0;fi
+ done
+}
+
+NODE_VERSION=$(node --version)
+check_node_version $NODE_VERSION
+if [[ $? == 1 ]]; then echo "node version is too old. please use v.7.6.0 or newer." && exit 1; fi
+echo "node version is new enough!"