-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathversion.js
30 lines (28 loc) · 937 Bytes
/
version.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
var Version = function(info, config) {
info = info || {};
this.config = config || {};
this.majorVersion = info.majorVersion || 0;
this.minorVersion = info.minorVersion || 0;
this.patchVersion = info.patchVersion || 1;
this.buildNumber = info.buildNumber || 0;
};
Version.prototype.toString = function() {
var format = this.config.format || '$major.$minor.$patch';
return format
.replace(/\$major/, this.majorVersion)
.replace(/\$minor/, this.minorVersion)
.replace(/\$patch/, this.patchVersion)
.replace(/\$build/, this.buildNumber);
};
Version.prototype.bumpBuildNumber = function() {
this.buildNumber++;
};
Version.prototype.toJson = function(options, space) {
return JSON.stringify({
majorVersion: this.majorVersion,
minorVersion: this.minorVersion,
patchVersion: this.patchVersion,
buildNumber: this.buildNumber
}, options, space);
};
module.exports = Version;