forked from rhdeck/react-native-push-notification
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.js
More file actions
55 lines (55 loc) · 1.68 KB
/
plugin.js
File metadata and controls
55 lines (55 loc) · 1.68 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const Path = require("path");
const fs = require("fs");
const wd = process.cwd();
module.exports = [
{
name: "add-google-services <path>",
description: "Add google-services.json file from path <path>",
func: (args, opts) => {
const googpath = args[0];
if (fs.existsSync(googpath)) {
const targetPath = Path.join(
wd,
"android",
"app",
"google-services.json"
);
fs.copyFileSync(googpath, targetPath);
console.log("Successfully populated ", targetPath);
} else {
console.log("Identified path does not exist: ", googpath, "Aborting.");
}
}
},
{
name: "set-application-id <newid>",
description:
"Set the android application ID in build.gradle to newid. (Usually to match your google-services)",
func: (args, opts) => {
const targetPath = Path.join(wd, "android", "app", "build.gradle");
if (!fs.existsSync(targetPath)) {
console.log("Could not find ", targetPath, "Aborting");
process.exit(1);
}
const t = fs.readFileSync(targetPath, { encoding: "UTF8" });
var lines = t.split("\n");
const keyLine = lines.findIndex(line => {
return line.indexOf("applicationId ") > -1;
});
if (keyLine) {
lines[keyLine] = 'applicationId "' + args[0] + '"';
const outtext = lines.join("\n");
fs.writeFileSync(targetPath, outtext);
console.log(
"Successfully updated applicationId to ",
args[0],
"in",
targetPath
);
} else {
console.log("Could not find applicationId in ", targetPath);
process.exit(1);
}
}
}
];