-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (26 loc) · 761 Bytes
/
index.js
File metadata and controls
35 lines (26 loc) · 761 Bytes
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
#!/usr/bin/env node
var fs = require('fs'),
util = require('util');
fs.readFile('package.json', function (err, data) {
var package = JSON.parse(data.toString());
var version = package.version.split('.');
var index = 1;
var major = process.argv[2] === '-m';
if (major) {
index = 0;
}
version[index] = parseInt(version[index], 10) + 1;
if (major) {
package.version = version[0] + '.0.0';
} else {
package.version = version.join('.');
}
fs.writeFile('package.json', JSON.stringify(package, null, 2),
function (err) {
if (err) {
console.log('Could not update file');
process.exit(1);
}
console.log(package.version);
});
});