-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.plugin.js
More file actions
42 lines (37 loc) · 1.06 KB
/
Copy pathapp.plugin.js
File metadata and controls
42 lines (37 loc) · 1.06 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
const { withDangerousMod, withPlugins } = require("@expo/config-plugins");
const {
mergeContents,
} = require("@expo/config-plugins/build/utils/generateCode");
const fs = require("fs");
const path = require("path");
async function readFileAsync(path) {
return fs.promises.readFile(path, "utf8");
}
async function saveFileAsync(path, content) {
return fs.promises.writeFile(path, content, "utf8");
}
const withAddMavenSource = (c) => {
return withDangerousMod(c, [
"android",
async (config) => {
const file = path.join(
config.modRequest.platformProjectRoot,
"build.gradle"
);
const contents = await readFileAsync(file);
await saveFileAsync(file, addMavenSource(contents));
return config;
},
]);
};
function addMavenSource(src) {
return mergeContents({
tag: `rn-add-github-source`,
src,
newSrc: "maven { url 'https://repo.brightcove.com/releases' }",
anchor: /jitpack.io/,
offset: 1,
comment: "//",
}).contents;
}
module.exports = (config) => withPlugins(config, [withAddMavenSource]);