mirror of https://github.com/keeweb/keeweb.git
fixed set-version script
This commit is contained in:
parent
0e379abcd2
commit
acc3d8f76b
|
@ -12,23 +12,21 @@ if (!/^\d+\.\d+\.\d+$/.test(version)) {
|
|||
console.log('Change version to ' + version);
|
||||
|
||||
// processFile('README.md', /\/download\/v[^\/]+/g);
|
||||
processFile('package.json', /"version": "\d+\.\d+\.\d+"+/g);
|
||||
processFile('package-lock.json', /"version": "\d+\.\d+\.\d+"+/);
|
||||
processFile('desktop/package.json', /"version": "\d+\.\d+\.\d+"+/g);
|
||||
processFile('package.json');
|
||||
processFile('package-lock.json');
|
||||
processFile('desktop/package.json');
|
||||
|
||||
console.log('Done');
|
||||
|
||||
function processFile(name, regex) {
|
||||
console.log('Replace: ' + name);
|
||||
name = path.join(__dirname, '..', name);
|
||||
let content = fs.readFileSync(name, 'utf8');
|
||||
let replCount = 0;
|
||||
content = content.replace(regex, match => {
|
||||
replCount++;
|
||||
return match.replace(/\d+\.\d+\.\d+/, version);
|
||||
});
|
||||
if (!replCount) {
|
||||
throw 'No match found!';
|
||||
const content = fs.readFileSync(name, 'utf8');
|
||||
const data = JSON.parse(content);
|
||||
if (!/\d+\.\d+\.\d+/.test(data.version)) {
|
||||
throw new Error('No match found!');
|
||||
}
|
||||
fs.writeFileSync(name, content, 'utf8');
|
||||
data.version = version;
|
||||
const newContent = JSON.stringify(data, null, 2) + '\n';
|
||||
fs.writeFileSync(name, newContent, 'utf8');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue