-
Notifications
You must be signed in to change notification settings - Fork 0
/
delay.js
67 lines (56 loc) · 1.67 KB
/
delay.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
let chalk = require('chalk');
let semverStable = require('semver-stable');
let semverUtils = require('semver-utils');
let semver = require('semver');
function compareVersions(v1, v2) {
if (!semver.diff(v1, v2)) {
return null;
}
v1 = semverUtils.parse(v1);
v2 = semverUtils.parse(v2);
return {
'major': v1.major - v2.major,
'minor': v1.minor - v2.minor,
'patch': v1.patch - v2.patch
};
}
function getMaxVersion(versions, range) {
if (range == null) {
range = ">0.0.0";
}
versions = versions.filter(function (version) {
return semverStable.is(version);
});
return semver.maxSatisfying(versions, range);
}
function isStable(version) {
return semverStable.is(version);
}
function projectDelay(delay, projectName = null) {
console.log(chalk.white(projectName + ' Project Total Delay :'));
var projetDelayScreen = null;
switch (delay) {
case null:
console.log(chalk.green('No Delay'));
break;
default:
if (delay.abandoned) {
console.log(chalk.red('Abandoned: ' + delay.abandoned));
}
if (delay.major) {
console.log(chalk.red('Major: ' + delay.major));
}
if (delay.minor) {
console.log(chalk.yellow('Minor: ' + delay.minor));
}
if (delay.patch) {
console.log(chalk.green('Patch: ' + delay.patch));
}
}
}
module.exports = {
projectDelay: projectDelay,
compareVersions: compareVersions,
getMaxVersion : getMaxVersion,
isStable : isStable
};