-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump-version.js
37 lines (30 loc) · 1.06 KB
/
bump-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
31
32
33
34
35
36
37
//bump-version.js
const fs = require('fs');
const path = require('path');
const packageJsonPath = path.join(__dirname, 'package.json');
const packageJson = require(packageJsonPath);
// Bestimmen des Versionsteils, der erhöht werden soll
const versionPart = process.argv[2]; // 'major', 'minor', 'patch'
let versionParts = packageJson.version.split('.').map(part => parseInt(part));
switch (versionPart) {
case 'major':
versionParts[0]++;
versionParts[1] = 0;
versionParts[2] = 0;
break;
case 'minor':
versionParts[1]++;
versionParts[2] = 0;
break;
case 'patch':
default:
versionParts[2]++;
break;
}
packageJson.version = versionParts.join('.');
// Zurückschreiben der package.json
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log(`Version updated to ${packageJson.version}`);
// Versionsnummer in Datei schreiben..
const content = `export const version = '${packageJson.version}';\n`;
fs.writeFileSync(path.join(__dirname, 'src', 'version.ts'), content);