Created
September 7, 2016 05:41
-
-
Save njleonzhang/11a22064dd48c2503a0a205f336efc9e to your computer and use it in GitHub Desktop.
append extend 8 to android code version.
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
#!/usr/bin/env node | |
var path = require('path'); | |
var fs = require('fs'); | |
var xml2js = require('xml2js'); | |
function xmlFileToJs(filename, cb) { | |
var filepath = path.normalize(path.join(__dirname, filename)); | |
fs.readFile(filepath, 'utf8', function (err, xmlStr) { | |
if (err) throw (err); | |
xml2js.parseString(xmlStr, {}, cb); | |
}); | |
} | |
function jsToXmlFile(filename, obj, cb) { | |
var filepath = path.normalize(path.join(__dirname, filename)); | |
var builder = new xml2js.Builder(); | |
var xml = builder.buildObject(obj); | |
fs.writeFile(filepath, xml, cb); | |
} | |
var androidManifestRPath = '../../platforms/android/AndroidManifest.xml'; | |
xmlFileToJs(androidManifestRPath, function(error, data) { | |
var config = data; | |
config.manifest.$['android:versionCode'] += '8'; | |
jsToXmlFile(androidManifestRPath, config) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code not running with Cordova 9.0, error:
Use this: https://gist.github.com/ricardoapaes/66f07c0a46c3e7dadf488aa66b93fff7