-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathversion.js
More file actions
27 lines (21 loc) · 824 Bytes
/
version.js
File metadata and controls
27 lines (21 loc) · 824 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
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const version = process.env.npm_package_version;
const mode = process.argv[2];
function replaceInFile(path, match, replacement) {
const data = fs.readFileSync(path, 'utf8');
switch (mode) {
case 'check':
if (!data.match(match))
throw `Error: no match found in '${path}'.`;
break;
case 'update':
console.log(`Updating app version in '${path}'...`);
fs.writeFileSync(path, data.replace(match, replacement), 'utf8');
break;
default:
throw 'Error: invalid mode!';
}
}
replaceInFile('CHANGELOG.md', '### Next version', `### Version ${version}`);
replaceInFile('LICENSE.md', /__Diffix for Desktop \d+\.\d+\.\d+__/, `__Diffix for Desktop ${version}__`);