forked from project-sunbird/cordova-plugin-genie-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_application_name.js
31 lines (23 loc) · 1.04 KB
/
add_application_name.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
module.exports = function (context) {
var APPLICATION_CLASS = "org.sunbird.SunbirdApplication";
var fs = context.requireCordovaModule('fs'),
path = context.requireCordovaModule('path');
console.log("Finding Manifest File");
var platformRoot = path.join(context.opts.projectRoot, 'platforms/android/app/src/main');
var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
if (fs.existsSync(manifestFile)) {
console.log("Manifest Found");
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);
})
console.log("Manifest Edited Successfully");
}
});
}
};