-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbumpConfig.mjs
40 lines (28 loc) · 1.1 KB
/
bumpConfig.mjs
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
38
39
40
import config from './config.json' assert {type: 'json'};
import pkg from './package.json' assert {type: 'json'};
import fs from 'fs'
import cp from 'child_process'
import { fileURLToPath } from 'url';
import path from 'path';
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
console.info('dirname', dirname);
const paths = {
config: path.resolve(dirname, './config.json'),
csproj: path.resolve(dirname, './src/FingerprintPro.ServerSdk/FingerprintPro.ServerSdk.csproj'),
}
console.info('paths', paths);
function bumpConfigVersion(version) {
config.packageVersion = version;
fs.writeFileSync(paths.config, JSON.stringify(config, null, 4));
}
function bumpCsprojVersion(version) {
const csproj = fs.readFileSync(paths.csproj, 'utf8');
// Replace <Version> tag with given version
const newCsproj = csproj.replace(/<Version>.*<\/Version>/, `<Version>${version}</Version>`);
console.info('newCsproj', newCsproj);
fs.writeFileSync(paths.csproj, newCsproj);
}
const version = pkg.version
bumpConfigVersion(version);
bumpCsprojVersion(version);