Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add golang support #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions fixers/upgrade-go.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright © 2020 Jan Keromnes.
// The following code is covered by the MIT license.

const { getData } = require("crawler-toolbox");
const { patchDom } = require("crawler-toolbox/build/utils");

const getLatestGoVersion = async () => {
const url = "https://golang.org/dl/";

let golangVersion = undefined
const result = await getData(url);
patchDom(result.content, ($) => {
// https://regex101.com/r/cJLyi6/1
const regex = /\/dl\/go(.*?).src.tar.gz/gm;
const links = [... $("a[href]")];
for (const l of links) {
const version = regex.exec(l.attribs["href"])?.[1];
if (version != undefined) {
golangVersion = version
break;
}
}
});

return golangVersion
};
exports.register = async (fixers) => {
const golangVersion = await getLatestGoVersion()
console.log(golangVersion)
fixers[0].push({
id: "upgrade-golang",
cmd: `todo`,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jankeromnes I am not familiar with sed, so I need your help on this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping

description: "Update pinned Go module versions",
});
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"test": "node tests.js"
},
"dependencies": {
"crawler-toolbox": "^1.0.1",
"minimist": "1.2.5"
},
"devDependencies": {}
Expand Down