generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfetch.js
31 lines (29 loc) · 762 Bytes
/
fetch.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
const fs = require("fs");
const fetch = function(path) {
return fs
.readFileSync(path)
.toString()
.split("\n")
.reduce((acc, current) => {
const [key, value] = current.trim().split(/\s+/);
if (value) {
switch (key) {
case "elixir":
acc[key] = value.replace(/-otp.+/, "");
break;
case "hugo":
const is_extended = value.startsWith("extended_");
acc[key] = JSON.stringify({
version: is_extended ? value.replace("extended_", "") : value,
is_extended,
});
break;
default:
acc[key] = value;
break;
}
}
return acc;
}, {});
};
module.exports = fetch;