Read go version from go.mod

This commit is contained in:
So Jomura 2022-04-29 11:11:36 +00:00 committed by GitHub
parent f5fe54e5a4
commit 55b9afc327
4 changed files with 76 additions and 22 deletions

View file

@ -266,3 +266,12 @@ export function makeSemver(version: string): string {
return `${verPart}${prereleasePart}`;
}
export function parseGoVersionFile(contents: string, isMod: boolean): string {
if (!isMod) {
return contents.trim();
}
const match = contents.match(/^go (\d+(\.\d+)*)/m);
return match ? match[1] : '';
}