-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathafterPluginAdd.js
36 lines (27 loc) · 1.07 KB
/
afterPluginAdd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
module.exports = function(context) {
var fs = require('fs'),
path = require('path');
var platformRoot = path.join(context.opts.projectRoot, 'platforms/android/app/src/main');
var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
if (fs.existsSync(manifestFile)) {
try {
fs.readFile(manifestFile, 'utf8', function (err,data) {
if (err) {
throw new Error('Unable to find AndroidManifest.xml: ' + err);
}
var appClass = 'com.netmera.cordova.plugin.NetmeraApplication';
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);
}
});
}
});
} catch(err) {
process.stdout.write(err);
}
}
}