mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 01:13:35 +00:00 
			
		
		
		
	feat: add node-lts-codename output
This commit is contained in:
		
							parent
							
								
									16352bb09b
								
							
						
					
					
						commit
						c81dbb113a
					
				@ -32,6 +32,8 @@ outputs:
 | 
			
		||||
    description: 'A boolean value to indicate if a cache was hit.'
 | 
			
		||||
  node-version:
 | 
			
		||||
    description: 'The installed node version.'
 | 
			
		||||
  node-lts-codename:
 | 
			
		||||
    description: "The installed node version's LTS Codename. Empty if the installed node release is not an LTS release."
 | 
			
		||||
runs:
 | 
			
		||||
  using: 'node16'
 | 
			
		||||
  main: 'dist/setup/index.js'
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										21
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -73683,6 +73683,9 @@ function printEnvDetailsAndSetOutput() {
 | 
			
		||||
            }
 | 
			
		||||
            core.info(`${tool}: ${output}`);
 | 
			
		||||
        }));
 | 
			
		||||
        promises.push(getLtsCodename().then(codename => {
 | 
			
		||||
            core.setOutput('node-lts-codename', codename);
 | 
			
		||||
        }));
 | 
			
		||||
        yield Promise.all(promises);
 | 
			
		||||
        core.endGroup();
 | 
			
		||||
    });
 | 
			
		||||
@ -73706,6 +73709,24 @@ function getToolVersion(tool, options) {
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function getLtsCodename() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            const { stdout, stderr, exitCode } = yield exec.getExecOutput('node', ["-p 'process.release.lts || process.exit(0)'"], {
 | 
			
		||||
                ignoreReturnCode: true,
 | 
			
		||||
                silent: true
 | 
			
		||||
            });
 | 
			
		||||
            if (exitCode > 0) {
 | 
			
		||||
                core.warning(`[warning]${stderr}`);
 | 
			
		||||
                return '';
 | 
			
		||||
            }
 | 
			
		||||
            return stdout;
 | 
			
		||||
        }
 | 
			
		||||
        catch (err) {
 | 
			
		||||
            return '';
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										28
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								src/main.ts
									
									
									
									
									
								
							@ -115,6 +115,12 @@ export async function printEnvDetailsAndSetOutput() {
 | 
			
		||||
    core.info(`${tool}: ${output}`);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  promises.push(
 | 
			
		||||
    getLtsCodename().then(codename => {
 | 
			
		||||
      core.setOutput('node-lts-codename', codename);
 | 
			
		||||
    })
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  await Promise.all(promises);
 | 
			
		||||
 | 
			
		||||
  core.endGroup();
 | 
			
		||||
@ -137,3 +143,25 @@ async function getToolVersion(tool: string, options: string[]) {
 | 
			
		||||
    return '';
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function getLtsCodename() {
 | 
			
		||||
  try {
 | 
			
		||||
    const {stdout, stderr, exitCode} = await exec.getExecOutput(
 | 
			
		||||
      'node',
 | 
			
		||||
      ["-p 'process.release.lts || process.exit(0)'"],
 | 
			
		||||
      {
 | 
			
		||||
        ignoreReturnCode: true,
 | 
			
		||||
        silent: true
 | 
			
		||||
      }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    if (exitCode > 0) {
 | 
			
		||||
      core.warning(`[warning]${stderr}`);
 | 
			
		||||
      return '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return stdout;
 | 
			
		||||
  } catch (err) {
 | 
			
		||||
    return '';
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user