Skip to content

Instantly share code, notes, and snippets.

@NQuinn27
Created April 11, 2018 22:24
Show Gist options
  • Save NQuinn27/4ae6d9fad4147cd5796f9fb8bab97c33 to your computer and use it in GitHub Desktop.
Save NQuinn27/4ae6d9fad4147cd5796f9fb8bab97c33 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
module.exports = function(context) {
var fs = context.requireCordovaModule('fs'),
path = context.requireCordovaModule('path');
var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');
var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
if (fs.existsSync(manifestFile)) {
fs.readFile(manifestFile, 'utf8', function (err,data) {
if (err) {
throw new Error('Unable to find AndroidManifest.xml: ' + err);
}
var appClass = 'com.popdeem.cordova.plugin.PopdeemApplication';
if (data.indexOf(appClass) == -1) {
var result = data.replace(/<application/g, '<application android:name="' + appClass + '"');
fs.writeFile(manifestFile, result, 'utf8', function (err) {
if (err) throw new Error('Unable to write into AndroidManifest.xml: ' + err);
})
}
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment