mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 01:03:33 +00:00 
			
		
		
		
	requested changes
This commit is contained in:
		
							parent
							
								
									63e6b4af5a
								
							
						
					
					
						commit
						658b51b920
					
				@ -72,7 +72,6 @@ describe('setup-node', () => {
 | 
				
			|||||||
    exSpy = jest.spyOn(tc, 'extractTar');
 | 
					    exSpy = jest.spyOn(tc, 'extractTar');
 | 
				
			||||||
    cacheSpy = jest.spyOn(tc, 'cacheDir');
 | 
					    cacheSpy = jest.spyOn(tc, 'cacheDir');
 | 
				
			||||||
    getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
 | 
					    getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
 | 
				
			||||||
    // @ts-ignore
 | 
					 | 
				
			||||||
    getDistSpy = jest.spyOn(im, 'getVersionsFromDist');
 | 
					    getDistSpy = jest.spyOn(im, 'getVersionsFromDist');
 | 
				
			||||||
    parseNodeVersionSpy = jest.spyOn(im, 'parseNodeVersionFile');
 | 
					    parseNodeVersionSpy = jest.spyOn(im, 'parseNodeVersionFile');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1302,37 +1301,25 @@ describe('setup-node', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      await main.run();
 | 
					      await main.run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      expect(dbgSpy.mock.calls[0][0]).toBe('requested v8 canary distribution');
 | 
					      expect(dbgSpy.mock.calls[0][0]).toBe('evaluating 0 versions');
 | 
				
			||||||
      expect(dbgSpy.mock.calls[1][0]).toBe('evaluating 17 versions');
 | 
					      expect(dbgSpy.mock.calls[1][0]).toBe('match not found');
 | 
				
			||||||
      expect(dbgSpy.mock.calls[2][0]).toBe(
 | 
					 | 
				
			||||||
        'matched: v20.0.0-v8-canary20221103f7e2421e91'
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      expect(logSpy.mock.calls[0][0]).toBe(
 | 
					      expect(logSpy.mock.calls[0][0]).toBe(
 | 
				
			||||||
        'getting v8-canary node version v20.0.0-v8-canary20221103f7e2421e91...'
 | 
					        `Attempting to download ${versionSpec}...`
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(logSpy.mock.calls[1][0]).toBe(
 | 
					      expect(dbgSpy.mock.calls[2][0]).toBe('No manifest cached');
 | 
				
			||||||
        'Attempt to find existing version in cache...'
 | 
					      expect(dbgSpy.mock.calls[3][0]).toBe(
 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      expect(dbgSpy.mock.calls[3][0]).toBe('evaluating 0 versions');
 | 
					 | 
				
			||||||
      expect(dbgSpy.mock.calls[4][0]).toBe('match not found');
 | 
					 | 
				
			||||||
      expect(logSpy.mock.calls[2][0]).toBe(
 | 
					 | 
				
			||||||
        'Attempting to download v20.0.0-v8-canary20221103f7e2421e91...'
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      expect(dbgSpy.mock.calls[5][0]).toBe('No manifest cached');
 | 
					 | 
				
			||||||
      expect(dbgSpy.mock.calls[6][0]).toBe(
 | 
					 | 
				
			||||||
        'Getting manifest from actions/node-versions@main'
 | 
					        'Getting manifest from actions/node-versions@main'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(dbgSpy.mock.calls[7][0].slice(0, 6)).toBe('check ');
 | 
					      expect(dbgSpy.mock.calls[4][0].slice(0, 6)).toBe('check ');
 | 
				
			||||||
      expect(dbgSpy.mock.calls[13][0].slice(0, 6)).toBe('check ');
 | 
					      expect(dbgSpy.mock.calls[10][0].slice(0, 6)).toBe('check ');
 | 
				
			||||||
      expect(logSpy.mock.calls[3][0]).toBe(
 | 
					      expect(logSpy.mock.calls[1][0]).toBe(
 | 
				
			||||||
        'Not found in manifest.  Falling back to download directly from Node'
 | 
					        'Not found in manifest.  Falling back to download directly from Node'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(dbgSpy.mock.calls[14][0]).toBe('evaluating 17 versions');
 | 
					      expect(dbgSpy.mock.calls[12][0]).toBe('evaluating 17 versions');
 | 
				
			||||||
      expect(dbgSpy.mock.calls[15][0]).toBe(
 | 
					      expect(dbgSpy.mock.calls[13][0]).toBe(
 | 
				
			||||||
        'matched: v20.0.0-v8-canary20221103f7e2421e91'
 | 
					        'matched: v20.0.0-v8-canary20221103f7e2421e91'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(dbgSpy.mock.calls[16][0]).toBe('requested v8 canary distribution');
 | 
					      expect(logSpy.mock.calls[2][0]).toBe(
 | 
				
			||||||
      expect(logSpy.mock.calls[4][0]).toBe(
 | 
					 | 
				
			||||||
        'Acquiring 20.0.0-v8-canary20221103f7e2421e91 - x64 from https://nodejs.org/download/v8-canary/v20.0.0-v8-canary20221103f7e2421e91/node-v20.0.0-v8-canary20221103f7e2421e91-linux-x64.tar.gz'
 | 
					        'Acquiring 20.0.0-v8-canary20221103f7e2421e91 - x64 from https://nodejs.org/download/v8-canary/v20.0.0-v8-canary20221103f7e2421e91/node-v20.0.0-v8-canary20221103f7e2421e91-linux-x64.tar.gz'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1373,14 +1360,12 @@ describe('setup-node', () => {
 | 
				
			|||||||
describe('helper methods', () => {
 | 
					describe('helper methods', () => {
 | 
				
			||||||
  it('is not LTS alias', async () => {
 | 
					  it('is not LTS alias', async () => {
 | 
				
			||||||
    const versionSpec = 'v99.0.0-v8-canary';
 | 
					    const versionSpec = 'v99.0.0-v8-canary';
 | 
				
			||||||
    // @ts-ignore
 | 
					 | 
				
			||||||
    const isLtsAlias = im.isLtsAlias(versionSpec);
 | 
					    const isLtsAlias = im.isLtsAlias(versionSpec);
 | 
				
			||||||
    expect(isLtsAlias).toBeFalsy();
 | 
					    expect(isLtsAlias).toBeFalsy();
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('is not isLatestSyntax', async () => {
 | 
					  it('is not isLatestSyntax', async () => {
 | 
				
			||||||
    const versionSpec = 'v99.0.0-v8-canary';
 | 
					    const versionSpec = 'v99.0.0-v8-canary';
 | 
				
			||||||
    // @ts-ignore
 | 
					 | 
				
			||||||
    const isLatestSyntax = im.isLatestSyntax(versionSpec);
 | 
					    const isLatestSyntax = im.isLatestSyntax(versionSpec);
 | 
				
			||||||
    expect(isLatestSyntax).toBeFalsy();
 | 
					    expect(isLatestSyntax).toBeFalsy();
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
@ -1388,14 +1373,12 @@ describe('helper methods', () => {
 | 
				
			|||||||
  describe('getNodejsDistUrl', () => {
 | 
					  describe('getNodejsDistUrl', () => {
 | 
				
			||||||
    it('dist url to be https://nodejs.org/download/v8-canary for input versionSpec', () => {
 | 
					    it('dist url to be https://nodejs.org/download/v8-canary for input versionSpec', () => {
 | 
				
			||||||
      const versionSpec = 'v99.0.0-v8-canary';
 | 
					      const versionSpec = 'v99.0.0-v8-canary';
 | 
				
			||||||
      // @ts-ignore
 | 
					 | 
				
			||||||
      const url = im.getNodejsDistUrl(versionSpec);
 | 
					      const url = im.getNodejsDistUrl(versionSpec);
 | 
				
			||||||
      expect(url).toBe('https://nodejs.org/download/v8-canary');
 | 
					      expect(url).toBe('https://nodejs.org/download/v8-canary');
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it('dist url to be https://nodejs.org/download/v8-canary for full versionSpec', () => {
 | 
					    it('dist url to be https://nodejs.org/download/v8-canary for full versionSpec', () => {
 | 
				
			||||||
      const versionSpec = 'v20.0.0-v8-canary20221103f7e2421e91';
 | 
					      const versionSpec = 'v20.0.0-v8-canary20221103f7e2421e91';
 | 
				
			||||||
      // @ts-ignore
 | 
					 | 
				
			||||||
      const url = im.getNodejsDistUrl(versionSpec);
 | 
					      const url = im.getNodejsDistUrl(versionSpec);
 | 
				
			||||||
      expect(url).toBe('https://nodejs.org/download/v8-canary');
 | 
					      expect(url).toBe('https://nodejs.org/download/v8-canary');
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
				
			|||||||
@ -41,16 +41,6 @@ describe('setup-node unit tests', () => {
 | 
				
			|||||||
        Distributions.CANARY
 | 
					        Distributions.CANARY
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    it('1.1.1-canary should throw exception', () => {
 | 
					 | 
				
			||||||
      expect(() => distributionOf('1.1.1-canary')).toThrow(
 | 
					 | 
				
			||||||
        'Canary version must have "-v8-canary suffix"'
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    it('1.1.1-canary20221103f7e2421e91 should throw exception', () => {
 | 
					 | 
				
			||||||
      expect(() => distributionOf('1.1.1-canary20221103f7e2421e91')).toThrow(
 | 
					 | 
				
			||||||
        'Canary version must have "-v8-canary suffix"'
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    it('1.1.1-nightly should be NIGHTLY', () => {
 | 
					    it('1.1.1-nightly should be NIGHTLY', () => {
 | 
				
			||||||
      expect(distributionOf('1.1.1-nightly')).toBe(Distributions.NIGHTLY);
 | 
					      expect(distributionOf('1.1.1-nightly')).toBe(Distributions.NIGHTLY);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										51
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -73218,23 +73218,20 @@ const semver = __importStar(__nccwpck_require__(5911));
 | 
				
			|||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
 | 
					const fs_1 = __importDefault(__nccwpck_require__(7147));
 | 
				
			||||||
var Distributions;
 | 
					var Distributions;
 | 
				
			||||||
(function (Distributions) {
 | 
					(function (Distributions) {
 | 
				
			||||||
    Distributions[Distributions["DEFAULT"] = 0] = "DEFAULT";
 | 
					    Distributions["DEFAULT"] = "default";
 | 
				
			||||||
    Distributions[Distributions["CANARY"] = 1] = "CANARY";
 | 
					    Distributions["CANARY"] = "v8-canary";
 | 
				
			||||||
    Distributions[Distributions["NIGHTLY"] = 2] = "NIGHTLY";
 | 
					    Distributions["NIGHTLY"] = "nightly";
 | 
				
			||||||
    Distributions[Distributions["RC"] = 3] = "RC";
 | 
					    Distributions["RC"] = "rc";
 | 
				
			||||||
})(Distributions = exports.Distributions || (exports.Distributions = {}));
 | 
					})(Distributions = exports.Distributions || (exports.Distributions = {}));
 | 
				
			||||||
exports.distributionOf = (versionSpec) => versionSpec.includes('-v8-canary')
 | 
					exports.distributionOf = (versionSpec) => {
 | 
				
			||||||
    ? Distributions.CANARY
 | 
					    if (versionSpec.includes('-v8-canary'))
 | 
				
			||||||
    : // TODO: i'd like to have this check, do you?
 | 
					        return Distributions.CANARY;
 | 
				
			||||||
        versionSpec.includes('-canary')
 | 
					    if (versionSpec.includes('nightly'))
 | 
				
			||||||
            ? (() => {
 | 
					        return Distributions.NIGHTLY;
 | 
				
			||||||
                throw Error('Canary version must have "-v8-canary suffix"');
 | 
					    if (semver.prerelease(versionSpec))
 | 
				
			||||||
            })()
 | 
					        return Distributions.RC;
 | 
				
			||||||
            : versionSpec.includes('nightly')
 | 
					    return Distributions.DEFAULT;
 | 
				
			||||||
                ? Distributions.NIGHTLY
 | 
					};
 | 
				
			||||||
                : semver.prerelease(versionSpec)
 | 
					 | 
				
			||||||
                    ? Distributions.RC
 | 
					 | 
				
			||||||
                    : Distributions.DEFAULT;
 | 
					 | 
				
			||||||
exports.semverVersionMatcherFactory = (range) => {
 | 
					exports.semverVersionMatcherFactory = (range) => {
 | 
				
			||||||
    const matcher = (potential) => semver.satisfies(potential, range);
 | 
					    const matcher = (potential) => semver.satisfies(potential, range);
 | 
				
			||||||
    matcher.factory = exports.semverVersionMatcherFactory;
 | 
					    matcher.factory = exports.semverVersionMatcherFactory;
 | 
				
			||||||
@ -73325,17 +73322,20 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os_1.default.arc
 | 
				
			|||||||
            manifest = yield getManifest(auth);
 | 
					            manifest = yield getManifest(auth);
 | 
				
			||||||
            versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
 | 
					            versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // TODO: 183-189 and 193-194   seems to be the same. Why do we need them?
 | 
					        if (isLatestSyntax(versionSpec)) {
 | 
				
			||||||
        if (isLatestSyntax(versionSpec) || distribution == Distributions.CANARY) {
 | 
					 | 
				
			||||||
            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
					            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
				
			||||||
            versionSpec = yield queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
					            versionSpec = yield queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
				
			||||||
            core.info(`getting ${distribution == Distributions.CANARY ? 'v8-canary' : 'latest'} node version ${versionSpec}...`);
 | 
					            core.info(`getting latest node version ${versionSpec}...`);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (distribution === Distributions.NIGHTLY && checkLatest) {
 | 
					        if ((distribution === Distributions.NIGHTLY ||
 | 
				
			||||||
 | 
					            distribution === Distributions.CANARY) &&
 | 
				
			||||||
 | 
					            checkLatest) {
 | 
				
			||||||
            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
					            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
				
			||||||
            versionSpec = yield queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
					            versionSpec = yield queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (checkLatest && distribution !== Distributions.NIGHTLY) {
 | 
					        if (checkLatest &&
 | 
				
			||||||
 | 
					            distribution !== Distributions.NIGHTLY &&
 | 
				
			||||||
 | 
					            distribution !== Distributions.CANARY) {
 | 
				
			||||||
            core.info('Attempt to resolve the latest version from manifest...');
 | 
					            core.info('Attempt to resolve the latest version from manifest...');
 | 
				
			||||||
            const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth, osArch, manifest);
 | 
					            const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth, osArch, manifest);
 | 
				
			||||||
            if (resolvedVersion) {
 | 
					            if (resolvedVersion) {
 | 
				
			||||||
@ -73347,7 +73347,6 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os_1.default.arc
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // check cache
 | 
					        // check cache
 | 
				
			||||||
        core.info('Attempt to find existing version in cache...');
 | 
					 | 
				
			||||||
        let toolPath;
 | 
					        let toolPath;
 | 
				
			||||||
        if (distribution === Distributions.DEFAULT) {
 | 
					        if (distribution === Distributions.DEFAULT) {
 | 
				
			||||||
            toolPath = tc.find('node', versionSpec, osArch);
 | 
					            toolPath = tc.find('node', versionSpec, osArch);
 | 
				
			||||||
@ -73562,13 +73561,10 @@ exports.evaluateVersions = evaluateVersions;
 | 
				
			|||||||
function getNodejsDistUrl(version) {
 | 
					function getNodejsDistUrl(version) {
 | 
				
			||||||
    switch (exports.distributionOf(version)) {
 | 
					    switch (exports.distributionOf(version)) {
 | 
				
			||||||
        case Distributions.CANARY:
 | 
					        case Distributions.CANARY:
 | 
				
			||||||
            core.debug('requested v8 canary distribution');
 | 
					 | 
				
			||||||
            return 'https://nodejs.org/download/v8-canary';
 | 
					            return 'https://nodejs.org/download/v8-canary';
 | 
				
			||||||
        case Distributions.NIGHTLY:
 | 
					        case Distributions.NIGHTLY:
 | 
				
			||||||
            core.debug('requested nightly distribution');
 | 
					 | 
				
			||||||
            return 'https://nodejs.org/download/nightly';
 | 
					            return 'https://nodejs.org/download/nightly';
 | 
				
			||||||
        case Distributions.RC:
 | 
					        case Distributions.RC:
 | 
				
			||||||
            core.debug('requested release candidates distribution');
 | 
					 | 
				
			||||||
            return 'https://nodejs.org/download/rc';
 | 
					            return 'https://nodejs.org/download/rc';
 | 
				
			||||||
        case Distributions.DEFAULT:
 | 
					        case Distributions.DEFAULT:
 | 
				
			||||||
            return 'https://nodejs.org/dist';
 | 
					            return 'https://nodejs.org/dist';
 | 
				
			||||||
@ -73602,7 +73598,7 @@ function queryDistForMatch(versionSpec, arch = os_1.default.arch(), nodeVersions
 | 
				
			|||||||
            core.info(`getting latest node version...`);
 | 
					            core.info(`getting latest node version...`);
 | 
				
			||||||
            return nodeVersions[0].version;
 | 
					            return nodeVersions[0].version;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let versions = [];
 | 
					        const versions = [];
 | 
				
			||||||
        nodeVersions.forEach((nodeVersion) => {
 | 
					        nodeVersions.forEach((nodeVersion) => {
 | 
				
			||||||
            // ensure this version supports your os and platform
 | 
					            // ensure this version supports your os and platform
 | 
				
			||||||
            if (nodeVersion.files.indexOf(dataFileName) >= 0) {
 | 
					            if (nodeVersion.files.indexOf(dataFileName) >= 0) {
 | 
				
			||||||
@ -73610,7 +73606,8 @@ function queryDistForMatch(versionSpec, arch = os_1.default.arch(), nodeVersions
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        // get the latest version that matches the version spec
 | 
					        // get the latest version that matches the version spec
 | 
				
			||||||
        return evaluateVersions(versions, versionSpec);
 | 
					        const version = evaluateVersions(versions, versionSpec);
 | 
				
			||||||
 | 
					        return version;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.queryDistForMatch = queryDistForMatch;
 | 
					exports.queryDistForMatch = queryDistForMatch;
 | 
				
			||||||
 | 
				
			|||||||
@ -31,25 +31,18 @@ interface INodeRelease extends tc.IToolRelease {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export enum Distributions {
 | 
					export enum Distributions {
 | 
				
			||||||
  DEFAULT,
 | 
					  DEFAULT = 'default',
 | 
				
			||||||
  CANARY,
 | 
					  CANARY = 'v8-canary',
 | 
				
			||||||
  NIGHTLY,
 | 
					  NIGHTLY = 'nightly',
 | 
				
			||||||
  RC
 | 
					  RC = 'rc'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const distributionOf = (versionSpec: string): Distributions =>
 | 
					export const distributionOf = (versionSpec: string): Distributions => {
 | 
				
			||||||
  versionSpec.includes('-v8-canary')
 | 
					  if (versionSpec.includes('-v8-canary')) return Distributions.CANARY;
 | 
				
			||||||
    ? Distributions.CANARY
 | 
					  if (versionSpec.includes('nightly')) return Distributions.NIGHTLY;
 | 
				
			||||||
    : // TODO: i'd like to have this check, do you?
 | 
					  if (semver.prerelease(versionSpec)) return Distributions.RC;
 | 
				
			||||||
    versionSpec.includes('-canary')
 | 
					  return Distributions.DEFAULT;
 | 
				
			||||||
    ? (() => {
 | 
					};
 | 
				
			||||||
        throw Error('Canary version must have "-v8-canary suffix"');
 | 
					 | 
				
			||||||
      })()
 | 
					 | 
				
			||||||
    : versionSpec.includes('nightly')
 | 
					 | 
				
			||||||
    ? Distributions.NIGHTLY
 | 
					 | 
				
			||||||
    : semver.prerelease(versionSpec)
 | 
					 | 
				
			||||||
    ? Distributions.RC
 | 
					 | 
				
			||||||
    : Distributions.DEFAULT;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface VersionMatcher {
 | 
					interface VersionMatcher {
 | 
				
			||||||
  (potential: string): boolean;
 | 
					  (potential: string): boolean;
 | 
				
			||||||
@ -190,23 +183,26 @@ export async function getNode(
 | 
				
			|||||||
    versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
 | 
					    versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // TODO: 183-189 and 193-194   seems to be the same. Why do we need them?
 | 
					  if (isLatestSyntax(versionSpec)) {
 | 
				
			||||||
  if (isLatestSyntax(versionSpec) || distribution == Distributions.CANARY) {
 | 
					 | 
				
			||||||
    nodeVersions = await getVersionsFromDist(versionSpec);
 | 
					    nodeVersions = await getVersionsFromDist(versionSpec);
 | 
				
			||||||
    versionSpec = await queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
					    versionSpec = await queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
				
			||||||
    core.info(
 | 
					    core.info(`getting latest node version ${versionSpec}...`);
 | 
				
			||||||
      `getting ${
 | 
					 | 
				
			||||||
        distribution == Distributions.CANARY ? 'v8-canary' : 'latest'
 | 
					 | 
				
			||||||
      } node version ${versionSpec}...`
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (distribution === Distributions.NIGHTLY && checkLatest) {
 | 
					  if (
 | 
				
			||||||
 | 
					    (distribution === Distributions.NIGHTLY ||
 | 
				
			||||||
 | 
					      distribution === Distributions.CANARY) &&
 | 
				
			||||||
 | 
					    checkLatest
 | 
				
			||||||
 | 
					  ) {
 | 
				
			||||||
    nodeVersions = await getVersionsFromDist(versionSpec);
 | 
					    nodeVersions = await getVersionsFromDist(versionSpec);
 | 
				
			||||||
    versionSpec = await queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
					    versionSpec = await queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (checkLatest && distribution !== Distributions.NIGHTLY) {
 | 
					  if (
 | 
				
			||||||
 | 
					    checkLatest &&
 | 
				
			||||||
 | 
					    distribution !== Distributions.NIGHTLY &&
 | 
				
			||||||
 | 
					    distribution !== Distributions.CANARY
 | 
				
			||||||
 | 
					  ) {
 | 
				
			||||||
    core.info('Attempt to resolve the latest version from manifest...');
 | 
					    core.info('Attempt to resolve the latest version from manifest...');
 | 
				
			||||||
    const resolvedVersion = await resolveVersionFromManifest(
 | 
					    const resolvedVersion = await resolveVersionFromManifest(
 | 
				
			||||||
      versionSpec,
 | 
					      versionSpec,
 | 
				
			||||||
@ -224,7 +220,6 @@ export async function getNode(
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // check cache
 | 
					  // check cache
 | 
				
			||||||
  core.info('Attempt to find existing version in cache...');
 | 
					 | 
				
			||||||
  let toolPath: string;
 | 
					  let toolPath: string;
 | 
				
			||||||
  if (distribution === Distributions.DEFAULT) {
 | 
					  if (distribution === Distributions.DEFAULT) {
 | 
				
			||||||
    toolPath = tc.find('node', versionSpec, osArch);
 | 
					    toolPath = tc.find('node', versionSpec, osArch);
 | 
				
			||||||
@ -521,13 +516,10 @@ export function evaluateVersions(
 | 
				
			|||||||
export function getNodejsDistUrl(version: string) {
 | 
					export function getNodejsDistUrl(version: string) {
 | 
				
			||||||
  switch (distributionOf(version)) {
 | 
					  switch (distributionOf(version)) {
 | 
				
			||||||
    case Distributions.CANARY:
 | 
					    case Distributions.CANARY:
 | 
				
			||||||
      core.debug('requested v8 canary distribution');
 | 
					 | 
				
			||||||
      return 'https://nodejs.org/download/v8-canary';
 | 
					      return 'https://nodejs.org/download/v8-canary';
 | 
				
			||||||
    case Distributions.NIGHTLY:
 | 
					    case Distributions.NIGHTLY:
 | 
				
			||||||
      core.debug('requested nightly distribution');
 | 
					 | 
				
			||||||
      return 'https://nodejs.org/download/nightly';
 | 
					      return 'https://nodejs.org/download/nightly';
 | 
				
			||||||
    case Distributions.RC:
 | 
					    case Distributions.RC:
 | 
				
			||||||
      core.debug('requested release candidates distribution');
 | 
					 | 
				
			||||||
      return 'https://nodejs.org/download/rc';
 | 
					      return 'https://nodejs.org/download/rc';
 | 
				
			||||||
    case Distributions.DEFAULT:
 | 
					    case Distributions.DEFAULT:
 | 
				
			||||||
      return 'https://nodejs.org/dist';
 | 
					      return 'https://nodejs.org/dist';
 | 
				
			||||||
@ -568,7 +560,7 @@ export async function queryDistForMatch(
 | 
				
			|||||||
    return nodeVersions[0].version;
 | 
					    return nodeVersions[0].version;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let versions: string[] = [];
 | 
					  const versions: string[] = [];
 | 
				
			||||||
  nodeVersions.forEach((nodeVersion: INodeVersion) => {
 | 
					  nodeVersions.forEach((nodeVersion: INodeVersion) => {
 | 
				
			||||||
    // ensure this version supports your os and platform
 | 
					    // ensure this version supports your os and platform
 | 
				
			||||||
    if (nodeVersion.files.indexOf(dataFileName) >= 0) {
 | 
					    if (nodeVersion.files.indexOf(dataFileName) >= 0) {
 | 
				
			||||||
@ -577,7 +569,8 @@ export async function queryDistForMatch(
 | 
				
			|||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // get the latest version that matches the version spec
 | 
					  // get the latest version that matches the version spec
 | 
				
			||||||
  return evaluateVersions(versions, versionSpec);
 | 
					  const version = evaluateVersions(versions, versionSpec);
 | 
				
			||||||
 | 
					  return version;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function getVersionsFromDist(
 | 
					export async function getVersionsFromDist(
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user