Skip to content

Commit

Permalink
Changed to bash compatible regex
Browse files Browse the repository at this point in the history
  • Loading branch information
greymistcube committed Jun 13, 2024
1 parent 372ac50 commit 7cf61b1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Libplanet.Tools/bin/npm-test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#!/bin/bash
set -e

# Taken from https://github.com/har7an/bash-semver-regex
# Regex for a semver digit
D='0|[1-9][0-9]*'
# Regex for a semver pre-release word
PW='[0-9]*[a-zA-Z-][0-9a-zA-Z-]*'
# Regex for a semver build-metadata word
MW='[0-9a-zA-Z-]+'

if [[ "$1" = "" ]]; then
echo error: missing version to download >&2
exit 1
elif [[ "$1" =~ ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$ ]]; then
elif [[ "$1" =~ ^($D)\.($D)\.($D)(-(($D|$PW)(\.($D|$PW))*))?(\+($MW(\.$MW)*))?$ ]]; then
version="$1"
else
echo error: invalid version number: "$1" >&2
Expand Down

0 comments on commit 7cf61b1

Please sign in to comment.