Skip to content

Commit

Permalink
Omit otp string for elixir versions
Browse files Browse the repository at this point in the history
  • Loading branch information
marocchino committed Jan 7, 2020
1 parent d264f39 commit f54c9de
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
10 changes: 9 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,15 @@ const fetch = function(path) {
.reduce((acc, current) => {
const [key, value] = current.trim().split(/\s+/);
if (value) {
acc[key] = value;
switch (key) {
case "elixir":
acc[key] = value.replace(/-otp.+/, "");
break;

default:
acc[key] = value;
break;
}
}
return acc;
}, {});
Expand Down
10 changes: 9 additions & 1 deletion fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ const fetch = function(path) {
.reduce((acc, current) => {
const [key, value] = current.trim().split(/\s+/);
if (value) {
acc[key] = value;
switch (key) {
case "elixir":
acc[key] = value.replace(/-otp.+/, "");
break;

default:
acc[key] = value;
break;
}
}
return acc;
}, {});
Expand Down
5 changes: 0 additions & 5 deletions fetch.test.js

This file was deleted.

2 changes: 2 additions & 0 deletions test/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodejs 13.0.0
elixir 1.9.4-otp-22
8 changes: 8 additions & 0 deletions test/fetch.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const fetch = require("../fetch");

test("load .tool-versions file to object", async () => {
expect(fetch("./test/.tool-versions")).toStrictEqual({
elixir: "1.9.4",
nodejs: "13.0.0"
});
});

0 comments on commit f54c9de

Please sign in to comment.