forked from voxeet/voxeet-uxkit-cordova
-
Notifications
You must be signed in to change notification settings - Fork 0
/
voxeet_application.js
37 lines (30 loc) · 1.07 KB
/
voxeet_application.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
37
#!/usr/bin/env node
module.exports = function(context) {
var APPLICATION_CLASS = "com.voxeet.toolkit.VoxeetApplication";
var fs = require('fs'),
path = require('path');
var folders = [
'platforms/android/app/src/main/',
'platforms/android/',
'android/app/src/main/'
];
folders
.map(folder => path.join(context.opts.projectRoot, folder))
.forEach(folder => {
var manifestFile = path.join(folder, 'AndroidManifest.xml');
if (fs.existsSync(manifestFile)) {
console.log("Found AndroidManifest, updating...");
fs.readFile(manifestFile, 'utf8', function (err, data) {
if (err) {
throw new Error('Unable to find AndroidManifest.xml: ' + err);
}
if (data.indexOf(APPLICATION_CLASS) == -1) {
var result = data.replace(/<application/g, '<application android:name="' + APPLICATION_CLASS + '"');
fs.writeFile(manifestFile, result, 'utf8', function (err) {
if (err) throw new Error('Unable to write into AndroidManifest.xml: ' + err);
})
}
});
}
});
};