added script which is updating version number in plugin.xml automatically

This commit is contained in:
Sefa Ilkimen
2017-10-04 12:59:33 +02:00
parent 52b2efe71b
commit 3476ff7ffb
4 changed files with 100 additions and 95 deletions

View File

@@ -0,0 +1,31 @@
const args = process.argv.slice(2);
const fs = require('mz/fs');
const path = require('path');
const xml2js = require('xml2js');
const xmlPath = path.join(__dirname, '..', 'plugin.xml');
const parse = xml => new Promise((resolve, reject) => {
const parser = new xml2js.Parser();
parser.parseString(xml, (error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
const stringify = obj => {
const builder = new xml2js.Builder();
return builder.buildObject(obj);
};
fs.readFile(xmlPath, 'utf-8')
.then(xml => parse(xml))
.then(parsed => {
parsed.plugin.$.version = args[0];
return fs.writeFile(xmlPath, stringify(parsed));
});