forked from quentintaranpino/nostrcheck-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.js
More file actions
28 lines (20 loc) · 825 Bytes
/
package.js
File metadata and controls
28 lines (20 loc) · 825 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
import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
import process from 'process';
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
const versionParts = packageJson.version.split('.');
let buildNumber = 0;
if (versionParts.length > 1) {
buildNumber = parseInt(versionParts[versionParts.length - 1], 10);
if (isNaN(buildNumber)) {
buildNumber = 0;
}
}
buildNumber += 1;
const formattedBuildNumber = buildNumber.toString().padStart(4, '0');
versionParts[versionParts.length - 1] = formattedBuildNumber;
packageJson.version = versionParts.join('.');
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');
execSync('npm install', { stdio: 'inherit' });