1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-10 08:44:47 +00:00
Funkin/source/funkin/util/VersionUtil.hx

32 lines
915 B
Haxe

package funkin.util;
import thx.semver.VersionRule;
import thx.semver.Version;
/**
* Remember, increment the patch version (1.0.x) if you make a bugfix,
* increment the minor version (1.x.0) if you make a new feature (but previous content is still compatible),
* and increment the major version (x.0.0) if you make a breaking change (e.g. new API or reorganized file format).
*/
class VersionUtil
{
/**
* Checks that a given verison number satisisfies a given version rule.
* Version rule can be complex, e.g. "1.0.x" or ">=1.0.0,<1.1.0", or anything NPM supports.
*/
public static function validateVersion(version:String, versionRule:String):Bool
{
try
{
var v:Version = version; // Perform a cast.
var vr:VersionRule = versionRule; // Perform a cast.
return v.satisfies(vr);
}
catch (e)
{
trace('[VERSIONUTIL] Invalid semantic version: ${version}');
return false;
}
}
}