-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
upversion.js
23 lines (16 loc) · 991 Bytes
/
upversion.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fs = require('fs');
console.log("%c:: UPDATING VERSION", "color: #007acc;");
let pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8').toString());
let version = pkgJson.version.split(".");
const lastIndex = version.length - 1;
version[lastIndex] = parseInt(version[lastIndex]) + 1;
// trata o formato: 1 -> 2.0.0 | 1.1 -> 1.2.0 | 1.1.1 -> 1.1.2
const newVersion = version.join(".") + (lastIndex <= 1 ? ".0".repeat(3 - (lastIndex + 1)) : "");
pkgJson.version = newVersion;
fs.writeFileSync('package.json', JSON.stringify(pkgJson, null, "\t"), 'utf-8');
console.log("... UPDATE PACKAGE.JSON");
pkgJson = JSON.parse(fs.readFileSync('projects/ion-calendar/package.json', 'utf-8').toString());
pkgJson.version = newVersion;
fs.writeFileSync('projects/ion-calendar/package.json', JSON.stringify(pkgJson, null, "\t"), 'utf-8');
console.log("... UPDATE ION-CALENDAR PACKAGE.JSON");
console.log("%c:: NEW VERSION ->", "color: #007acc;", pkgJson.version);