Skip to content

Commit

Permalink
Merge pull request #240 from BranchMetrics/chore/calculate-plugin.xml…
Browse files Browse the repository at this point in the history
…-version-number

chore: calculate version number from packge.json and stick it into plugin.xml on semantic release
  • Loading branch information
ethanneff authored Nov 17, 2016
2 parents 8585d6d + c45824a commit be4df83
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@ function genNpmPluginXML() {

fs.writeFileSync('plugin.xml', xml);
};
// first match only!
var PLUGIN_XML_VERSION_REGEX = /^\s*version=\"[\d\.]*\"\>$/m;
gulp.task('update-plugin-xml-version', () => {
var versionNumber = require('./package.json').version;
// this will break if plugin.xml is not formatted exactly as we expect
// so you might end up needing to fix the regex
for (target of [ '.xml', '.template.xml' ]) {
var pluginXML = fs.readFileSync('plugin' + target, 'utf8');
var newVersionXML = ` version="${versionNumber}">`;
pluginXML = pluginXML.replace(PLUGIN_XML_VERSION_REGEX, newVersionXML);
fs.writeFileSync('plugin' + target, pluginXML);
}

});
// generate plugin.xml for local development
// here we reference the frameworks instead of all the files directly
function getDevPluginXML() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"license": "MIT",
"scripts": {
"prerelease": "gulp prerelease",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"semantic-release": "semantic-release pre && gulp update-plugin-xml-version && npm publish && semantic-release post",
"commit": "git-cz"
},
"dependencies": {
Expand Down

0 comments on commit be4df83

Please sign in to comment.