15 lines
481 B
TypeScript
15 lines
481 B
TypeScript
export const versionCompat = (version: string, targetVersion: string) => {
|
|
if (targetVersion === "*") return true;
|
|
if (targetVersion === version) return true;
|
|
if (targetVersion.startsWith("^")) {
|
|
const versionSplit = version.split(".");
|
|
const targetVersionSplit = targetVersion.split(".");
|
|
for (let i = 0; i < versionSplit.length; i++) {
|
|
if (versionSplit[i] ?? "0" > targetVersionSplit[i] ?? "0") {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
};
|