-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfab6e6
commit 31832eb
Showing
8 changed files
with
234 additions
and
104 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const VPAT = /^\d+(\.\d+){0,2}$/; | ||
|
||
/** | ||
* Compares two versions | ||
* @return true if local is up to date, false otherwise | ||
* @param local | ||
* @param remote | ||
*/ | ||
export function upToDate(local: string, remote: string) { | ||
if (!local || !remote || local.length === 0 || remote.length === 0) | ||
return false; | ||
if (local == remote) return true; | ||
if (VPAT.test(local) && VPAT.test(remote)) { | ||
const lparts = local.split('.'); | ||
while (lparts.length < 3) lparts.push('0'); | ||
const rparts = remote.split('.'); | ||
while (rparts.length < 3) rparts.push('0'); | ||
for (let i = 0; i < 3; i++) { | ||
const l = parseInt(lparts[i], 10); | ||
const r = parseInt(rparts[i], 10); | ||
if (l === r) continue; | ||
return l > r; | ||
} | ||
return true; | ||
} else { | ||
return local >= remote; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters