mirror of
				https://kkgithub.com/actions/setup-node.git
				synced 2025-11-04 12:46:16 +08:00 
			
		
		
		
	Support lts/-n aliases (#481)
This commit is contained in:
		
							
								
								
									
										14
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -70756,10 +70756,18 @@ function resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
 | 
			
		||||
        throw new Error(`Unable to parse LTS alias for Node version '${versionSpec}'`);
 | 
			
		||||
    }
 | 
			
		||||
    core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`);
 | 
			
		||||
    // Supported formats are `lts/<alias>` and `lts/*`. Where asterisk means highest possible LTS.
 | 
			
		||||
    // Supported formats are `lts/<alias>`, `lts/*`, and `lts/-n`. Where asterisk means highest possible LTS and -n means the nth-highest.
 | 
			
		||||
    const n = Number(alias);
 | 
			
		||||
    const aliases = Object.fromEntries(manifest
 | 
			
		||||
        .filter(x => x.lts && x.stable === stable)
 | 
			
		||||
        .map(x => [x.lts.toLowerCase(), x])
 | 
			
		||||
        .reverse());
 | 
			
		||||
    const numbered = Object.values(aliases);
 | 
			
		||||
    const release = alias === '*'
 | 
			
		||||
        ? manifest.find(x => !!x.lts && x.stable === stable)
 | 
			
		||||
        : manifest.find(x => { var _a; return ((_a = x.lts) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === alias && x.stable === stable; });
 | 
			
		||||
        ? numbered[numbered.length - 1]
 | 
			
		||||
        : n < 0
 | 
			
		||||
            ? numbered[numbered.length - 1 + n]
 | 
			
		||||
            : aliases[alias];
 | 
			
		||||
    if (!release) {
 | 
			
		||||
        throw new Error(`Unable to find LTS release '${alias}' for Node version '${versionSpec}'.`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user