if-ver
Version:
simple if-version check for node
27 lines (17 loc) • 750 B
Plain Text
Usage: if-ver [comparison-operator] [semantic-version]
Check installed node version against a requested version using comparison operator.
The main purpose of this script is make it easier to only run scripts if the version is correct.
Comparison operators:
-eq - is equal to
-ne - is not equal to
-gt - is greater than
-lt - is less than
-ge - is greater than or equal to
-le - is less than or equal to
Examples:
Only run eslint if node version is at least 4:
if-ver -ge 4 || exit 0; eslint *.js
Only compile typescript if node version is at least 4.2:
if-ver -ge 4.2 || exit 0; tsc
Only run webpack if node version is (>= 4.3 && <5) || > 5.10:
(if-ver -ge 4.3 && if-ver -lt 5) || if-ver -gt 5.10 || exit 0; webpack