Skip to content

Commit

Permalink
remove unnecessary dist call
Browse files Browse the repository at this point in the history
  • Loading branch information
panticmilos committed May 19, 2022
1 parent 808c8f9 commit 141334f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 7 additions & 4 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62346,6 +62346,7 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
let manifest;
let osPlat = os.platform();
let osArch = translateArchToDistUrl(arch);
let latestVersionResolved = false;
if (isLtsAlias(versionSpec)) {
core.info('Attempt to resolve LTS alias from manifest...');
// No try-catch since it's not possible to resolve LTS alias without manifest
Expand All @@ -62365,6 +62366,7 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
}
if (isLatestSyntax(versionSpec)) {
versionSpec = yield queryDistForMatch(versionSpec, arch);
latestVersionResolved = true;
core.info(`getting latest node version...`);
}
// check cache
Expand Down Expand Up @@ -62407,7 +62409,7 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
// Download from nodejs.org
//
if (!downloadPath) {
info = yield getInfoFromDist(versionSpec, arch);
info = yield getInfoFromDist(versionSpec, arch, latestVersionResolved);
if (!info) {
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
}
Expand Down Expand Up @@ -62507,12 +62509,13 @@ function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchTo
return info;
});
}
function getInfoFromDist(versionSpec, arch = os.arch()) {
function getInfoFromDist(versionSpec, arch = os.arch(), latestVersionResolved) {
return __awaiter(this, void 0, void 0, function* () {
let osPlat = os.platform();
let osArch = translateArchToDistUrl(arch);
let version;
version = yield queryDistForMatch(versionSpec, arch);
let version = latestVersionResolved
? versionSpec
: yield queryDistForMatch(versionSpec, arch);
if (!version) {
return null;
}
Expand Down
12 changes: 8 additions & 4 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function getNode(
let manifest: INodeRelease[] | undefined;
let osPlat: string = os.platform();
let osArch: string = translateArchToDistUrl(arch);
let latestVersionResolved: boolean = false;

if (isLtsAlias(versionSpec)) {
core.info('Attempt to resolve LTS alias from manifest...');
Expand Down Expand Up @@ -69,6 +70,7 @@ export async function getNode(

if (isLatestSyntax(versionSpec)) {
versionSpec = await queryDistForMatch(versionSpec, arch);
latestVersionResolved = true;
core.info(`getting latest node version...`);
}

Expand Down Expand Up @@ -125,7 +127,7 @@ export async function getNode(
// Download from nodejs.org
//
if (!downloadPath) {
info = await getInfoFromDist(versionSpec, arch);
info = await getInfoFromDist(versionSpec, arch, latestVersionResolved);
if (!info) {
throw new Error(
`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
Expand Down Expand Up @@ -271,14 +273,16 @@ async function getInfoFromManifest(

async function getInfoFromDist(
versionSpec: string,
arch: string = os.arch()
arch: string = os.arch(),
latestVersionResolved?: boolean
): Promise<INodeVersionInfo | null> {
let osPlat: string = os.platform();
let osArch: string = translateArchToDistUrl(arch);

let version: string;
let version: string = latestVersionResolved
? versionSpec
: await queryDistForMatch(versionSpec, arch);

version = await queryDistForMatch(versionSpec, arch);
if (!version) {
return null;
}
Expand Down

0 comments on commit 141334f

Please sign in to comment.