Skip to content

Commit

Permalink
build: add regex to validate bump script input
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Jun 28, 2024
1 parent ad340e9 commit 52e424d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bump_version.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,20 @@ class VersionUpgrade {
}

this.version = argv[2];
if (!this._isValidVersion(this.version)) {
console.error("Invalid version format. Expected 'X.X.X'.");
return;
}
this.tag = "v" + this.version;
console.log("Bumping version to " + this.version);
console.log("Bumping tag to " + this.tag);
this._runRelease();
}

_isValidVersion(version) {
const versionPattern = /^\d+\.\d+\.\d+(-[a-zA-Z0-9]+)?$/;
return versionPattern.test(version);
}
}

new VersionUpgrade().upgrade(process.argv);

0 comments on commit 52e424d

Please # to comment.