forked from HughIsaacs2/Cordova-Android-TV-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathpatch.js
More file actions
27 lines (25 loc) · 1.14 KB
/
patch.js
File metadata and controls
27 lines (25 loc) · 1.14 KB
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
#!/usr/bin/env node
module.exports = function (context) {
var fs = require('fs'),
path = require('path'),
platformRoot = path.join(context.opts.projectRoot, 'platforms/android'),
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);
}
if (!(/<application[^>]*\bandroid:banner/).test(data)) {
console.log('Adding banner attribute');
data = data.replace(/<application/g, '<application android:banner="@drawable/banner"');
}
if (!(/<application[^>]*\bandroid:isGame/).test(data)) {
console.log('Adding isGame attribute');
data = data.replace(/<application/g, '<application android:isGame="false"');
}
fs.writeFile(manifestFile, data, 'utf8', function (err) {
if (err) throw new Error('Unable to write into AndroidManifest.xml: ' + err);
})
});
}
};