polish code

pull/300/head^2
Dmitry Shibanov 2 years ago
parent 5a5cdc8151
commit 7e3178723a

@ -63236,17 +63236,7 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) {
manifest = yield getManifest(auth);
let stableVersion = yield resolveStableVersionInput(versionSpec, arch, osPlat, manifest);
if (!stableVersion) {
let archFilter = sys.getArch(arch);
let platFilter = sys.getPlatform();
const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
let candidates = yield module.exports.getVersionsDist(dlUrl);
if (!candidates) {
throw new Error(`golang download url did not return results`);
}
const fixedCandidates = candidates.map(item => {
return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) });
});
stableVersion = yield resolveStableVersionInput(versionSpec, archFilter, platFilter, fixedCandidates);
stableVersion = yield resolveStableVersionDist(versionSpec, arch);
if (!stableVersion) {
throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`);
}
@ -63489,6 +63479,22 @@ function parseGoVersionFile(versionFilePath) {
return contents.trim();
}
exports.parseGoVersionFile = parseGoVersionFile;
function resolveStableVersionDist(versionSpec, arch) {
return __awaiter(this, void 0, void 0, function* () {
let archFilter = sys.getArch(arch);
let platFilter = sys.getPlatform();
const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
let candidates = yield module.exports.getVersionsDist(dlUrl);
if (!candidates) {
throw new Error(`golang download url did not return results`);
}
const fixedCandidates = candidates.map(item => {
return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) });
});
const stableVersion = yield resolveStableVersionInput(versionSpec, archFilter, platFilter, fixedCandidates);
return stableVersion;
});
}
function resolveStableVersionInput(versionSpec, arch, platform, manifest) {
return __awaiter(this, void 0, void 0, function* () {
const releases = manifest

@ -52,30 +52,7 @@ export async function getGo(
);
if (!stableVersion) {
let archFilter = sys.getArch(arch);
let platFilter = sys.getPlatform();
const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all';
let candidates:
| IGoVersion[]
| null = await module.exports.getVersionsDist(dlUrl);
if (!candidates) {
throw new Error(`golang download url did not return results`);
}
const fixedCandidates = candidates.map(item => {
return {
...item,
version: makeSemver(item.version)
};
});
stableVersion = await resolveStableVersionInput(
versionSpec,
archFilter,
platFilter,
fixedCandidates
);
stableVersion = await resolveStableVersionDist(versionSpec, arch);
if (!stableVersion) {
throw new Error(
`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`
@ -389,6 +366,34 @@ export function parseGoVersionFile(versionFilePath: string): string {
return contents.trim();
}
async function resolveStableVersionDist(versionSpec: string, arch: string) {
let archFilter = sys.getArch(arch);
let platFilter = sys.getPlatform();
const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all';
let candidates: IGoVersion[] | null = await module.exports.getVersionsDist(
dlUrl
);
if (!candidates) {
throw new Error(`golang download url did not return results`);
}
const fixedCandidates = candidates.map(item => {
return {
...item,
version: makeSemver(item.version)
};
});
const stableVersion = await resolveStableVersionInput(
versionSpec,
archFilter,
platFilter,
fixedCandidates
);
return stableVersion;
}
export async function resolveStableVersionInput(
versionSpec: string,
arch: string,

Loading…
Cancel
Save