forked from Dutchie1990/FlagsmithFeatureFlagRemoval
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.js
38 lines (35 loc) · 869 Bytes
/
github.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
38
const { Octokit } = require("@octokit/rest");
async function getGithubConfigFlags(auth, ownerRepo, path, ref) {
const flags = [];
const owner = ownerRepo.split("/")[0];
const repo = ownerRepo.split("/")[1];
const client = new Octokit({
auth,
});
return client
.request("GET /repos/{owner}/{repo}/contents/{path}", {
owner,
repo,
path,
ref,
mediaType: {
format: "raw",
},
})
.then((response) => {
const extractedValues = response.data.split(",");
extractedValues.forEach((el) => {
var mySubString = el.substring(
el.indexOf("'") + 1,
el.lastIndexOf("'")
);
flags.push(mySubString);
});
flags.pop();
return flags;
})
.catch((er) => {
console.log(er.request);
});
}
module.exports = getGithubConfigFlags;