-
-
Save nuno/14948ec474c48af02a14 to your computer and use it in GitHub Desktop.
alloy.jmk to bump version on build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var path = require('path'); | |
task("pre:compile", function(event, logger) { | |
var tiappxml = path.join(event.dir.project, 'tiapp.xml'); | |
var tiapp = fs.readFileSync(tiappxml, { | |
encoding : 'utf-8' | |
}); | |
tiapp = tiapp.replace(/(android:versionCode=")([^"]+)(")/, function(match, before, versionCode, after) { | |
versionCode = parseInt(versionCode, 10) + 1; | |
logger.info('Bumped android:versionCode to: ' + versionCode); | |
return before + versionCode + after; | |
}); | |
tiapp = tiapp.replace(/(<key>CFBundleVersion<\/key>\s*<string>)([^<]+)(<\/string>)/mg, function(match, before, CFBundleVersion, after) { | |
CFBundleVersion = parseInt(CFBundleVersion, 10) + 1; | |
logger.info('Bumped CFBundleVersion to: ' + CFBundleVersion); | |
return before + CFBundleVersion + after; | |
}); | |
fs.writeFileSync(tiappxml, tiapp); | |
logger.info('building project at ' + event.dir.project); | |
}); | |
task("post:compile", function(event, logger) { | |
logger.info('compile finished!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment