-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-version.js
26 lines (20 loc) · 919 Bytes
/
update-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
const fs = require('fs');
const path = require('path');
// Check if UPT_VER environment variable is true
if (process.env.UPT_VER === 'true') {
// Path to package.json
const packageJsonPath = path.join(__dirname, 'package.json');
// Read and parse package.json
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
// Split version and increment the patch number
const [major, minor, patch] = packageJson.version.split('.').map(Number);
const newVersion = `${major}.${minor}.${patch + 1}`;
// Update the version in package.json
packageJson.version = newVersion;
// Write the updated version back to package.json
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
// Log the updated version to verify
console.log(`Version updated to ${packageJson.version}`);
} else {
console.log('Version update skipped. Set UPT_VER=true to update.');
}