MCPcopy Index your code
hub / github.com/actions/setup-node / run

Function run

src/main.ts:14–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12import {State} from './constants';
13
14export async function run() {
15 try {
16 //
17 // Version is optional. If supplied, install / use from the tool cache
18 // If not supplied then task is still used to setup proxy, auth, etc...
19 //
20 const version = resolveVersionInput();
21
22 let arch = core.getInput('architecture');
23 const cache = core.getInput('cache');
24 const packagemanagercache =
25 (core.getInput('package-manager-cache') || 'true').toUpperCase() ===
26 'TRUE';
27
28 // if architecture supplied but node-version is not
29 // if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
30 if (arch && !version) {
31 core.warning(
32 '`architecture` is provided but `node-version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `node-version`'
33 );
34 }
35
36 if (!arch) {
37 arch = os.arch();
38 }
39
40 if (version) {
41 const token = core.getInput('token');
42 const auth = !token ? undefined : `token ${token}`;
43 const mirror = core.getInput('mirror');
44 const mirrorToken = core.getInput('mirror-token');
45 const stable =
46 (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
47 const checkLatest =
48 (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
49 const nodejsInfo = {
50 versionSpec: version,
51 checkLatest,
52 auth,
53 stable,
54 arch,
55 mirror,
56 mirrorToken
57 };
58 const nodeDistribution = getNodejsDistribution(nodejsInfo);
59 await nodeDistribution.setupNodeJs();
60 }
61
62 await printEnvDetailsAndSetOutput();
63
64 const registryUrl: string = core.getInput('registry-url');
65 if (registryUrl) {
66 auth.configAuthentication(registryUrl);
67 }
68
69 const cacheDependencyPath = core.getInput('cache-dependency-path');
70
71 if (isCacheFeatureAvailable()) {

Callers 1

setup-node.tsFile · 0.90

Calls 7

getNodejsDistributionFunction · 0.90
isCacheFeatureAvailableFunction · 0.90
restoreCacheFunction · 0.90
resolveVersionInputFunction · 0.85
setupNodeJsMethod · 0.80

Tested by

no test coverage detected