mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-19 21:04:45 +00:00
Add support for v8-canary, nightly and rc (#655)
This commit is contained in:
parent
92a57f4a93
commit
64ed1c7eab
24 changed files with 3976 additions and 1648 deletions
60
src/main.ts
60
src/main.ts
|
@ -1,12 +1,14 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as installer from './installer';
|
||||
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
|
||||
import * as auth from './authutil';
|
||||
import * as path from 'path';
|
||||
import {restoreCache} from './cache-restore';
|
||||
import {isGhes, isCacheFeatureAvailable} from './cache-utils';
|
||||
import os from 'os';
|
||||
import {isCacheFeatureAvailable} from './cache-utils';
|
||||
import {getNodejsDistribution} from './distributions/installer-factory';
|
||||
import {parseNodeVersionFile, printEnvDetailsAndSetOutput} from './util';
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
|
@ -38,7 +40,15 @@ export async function run() {
|
|||
(core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
||||
const checkLatest =
|
||||
(core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
||||
await installer.getNode(version, stable, checkLatest, auth, arch);
|
||||
const nodejsInfo = {
|
||||
versionSpec: version,
|
||||
checkLatest,
|
||||
auth,
|
||||
stable,
|
||||
arch
|
||||
};
|
||||
const nodeDistribution = getNodejsDistribution(nodejsInfo);
|
||||
await nodeDistribution.setupNodeJs();
|
||||
}
|
||||
|
||||
await printEnvDetailsAndSetOutput();
|
||||
|
@ -93,48 +103,10 @@ function resolveVersionInput(): string {
|
|||
);
|
||||
}
|
||||
|
||||
version = installer.parseNodeVersionFile(
|
||||
fs.readFileSync(versionFilePath, 'utf8')
|
||||
);
|
||||
version = parseNodeVersionFile(fs.readFileSync(versionFilePath, 'utf8'));
|
||||
|
||||
core.info(`Resolved ${versionFileInput} as ${version}`);
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
export async function printEnvDetailsAndSetOutput() {
|
||||
core.startGroup('Environment details');
|
||||
|
||||
const promises = ['node', 'npm', 'yarn'].map(async tool => {
|
||||
const output = await getToolVersion(tool, ['--version']);
|
||||
|
||||
if (tool === 'node') {
|
||||
core.setOutput(`${tool}-version`, output);
|
||||
}
|
||||
|
||||
core.info(`${tool}: ${output}`);
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
core.endGroup();
|
||||
}
|
||||
|
||||
async function getToolVersion(tool: string, options: string[]) {
|
||||
try {
|
||||
const {stdout, stderr, exitCode} = await exec.getExecOutput(tool, options, {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
});
|
||||
|
||||
if (exitCode > 0) {
|
||||
core.warning(`[warning]${stderr}`);
|
||||
return '';
|
||||
}
|
||||
|
||||
return stdout.trim();
|
||||
} catch (err) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue