mirror of
				https://gitea.com/actions/setup-node.git
				synced 2025-10-29 15:52:42 +08:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			v3.5.0
			...
			kotewar/up
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					c81d8ad96d | ||
| 
						 | 
					c96ab56c5b | 
@@ -249,6 +249,21 @@ describe('setup-node', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    let expPath = path.join(toolPath, 'bin');
 | 
					    let expPath = path.join(toolPath, 'bin');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    expect(getExecOutputSpy).toHaveBeenCalledWith(
 | 
				
			||||||
 | 
					      'node',
 | 
				
			||||||
 | 
					      ['--version'],
 | 
				
			||||||
 | 
					      expect.anything()
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    expect(getExecOutputSpy).toHaveBeenCalledWith(
 | 
				
			||||||
 | 
					      'npm',
 | 
				
			||||||
 | 
					      ['--version'],
 | 
				
			||||||
 | 
					      expect.anything()
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    expect(getExecOutputSpy).toHaveBeenCalledWith(
 | 
				
			||||||
 | 
					      'yarn',
 | 
				
			||||||
 | 
					      ['--version'],
 | 
				
			||||||
 | 
					      expect.anything()
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    expect(dlSpy).toHaveBeenCalled();
 | 
					    expect(dlSpy).toHaveBeenCalled();
 | 
				
			||||||
    expect(exSpy).toHaveBeenCalled();
 | 
					    expect(exSpy).toHaveBeenCalled();
 | 
				
			||||||
    expect(logSpy).toHaveBeenCalledWith(
 | 
					    expect(logSpy).toHaveBeenCalledWith(
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										42
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										42
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@@ -73618,14 +73618,7 @@ function run() {
 | 
				
			|||||||
                const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
 | 
					                const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
 | 
				
			||||||
                yield installer.getNode(version, stable, checkLatest, auth, arch);
 | 
					                yield installer.getNode(version, stable, checkLatest, auth, arch);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // Output version of node is being used
 | 
					            yield printEnvDetailsAndSetOutput();
 | 
				
			||||||
            try {
 | 
					 | 
				
			||||||
                const { stdout: installedVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true, silent: true });
 | 
					 | 
				
			||||||
                core.setOutput('node-version', installedVersion.trim());
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            catch (err) {
 | 
					 | 
				
			||||||
                core.setOutput('node-version', '');
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            const registryUrl = core.getInput('registry-url');
 | 
					            const registryUrl = core.getInput('registry-url');
 | 
				
			||||||
            const alwaysAuth = core.getInput('always-auth');
 | 
					            const alwaysAuth = core.getInput('always-auth');
 | 
				
			||||||
            if (registryUrl) {
 | 
					            if (registryUrl) {
 | 
				
			||||||
@@ -73665,6 +73658,39 @@ function resolveVersionInput() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    return version;
 | 
					    return version;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					function printEnvDetailsAndSetOutput() {
 | 
				
			||||||
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
 | 
					        core.startGroup('Environment details');
 | 
				
			||||||
 | 
					        const promises = ['node', 'npm', 'yarn'].map((tool) => __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
 | 
					            const output = yield getToolVersion(tool, ['--version']);
 | 
				
			||||||
 | 
					            if (tool === 'node') {
 | 
				
			||||||
 | 
					                core.setOutput(`${tool}-version`, output);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            core.info(`${tool}: ${output}`);
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					        yield Promise.all(promises);
 | 
				
			||||||
 | 
					        core.endGroup();
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					exports.printEnvDetailsAndSetOutput = printEnvDetailsAndSetOutput;
 | 
				
			||||||
 | 
					function getToolVersion(tool, options) {
 | 
				
			||||||
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            const { stdout, stderr, exitCode } = yield exec.getExecOutput(tool, options, {
 | 
				
			||||||
 | 
					                ignoreReturnCode: true,
 | 
				
			||||||
 | 
					                silent: true
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            if (exitCode > 0) {
 | 
				
			||||||
 | 
					                core.warning(`[warning]${stderr}`);
 | 
				
			||||||
 | 
					                return '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return stdout;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (err) {
 | 
				
			||||||
 | 
					            return '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/***/ }),
 | 
					/***/ }),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -283,3 +283,6 @@ steps:
 | 
				
			|||||||
  run: yarn install --immutable
 | 
					  run: yarn install --immutable
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
NOTE: As per https://github.com/actions/setup-node/issues/49 you cannot use `secrets.GITHUB_TOKEN` to access private GitHub Packages within the same organisation but in a different repository.
 | 
					NOTE: As per https://github.com/actions/setup-node/issues/49 you cannot use `secrets.GITHUB_TOKEN` to access private GitHub Packages within the same organisation but in a different repository.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### always-auth input
 | 
				
			||||||
 | 
					The always-auth input sets `always-auth=true` in .npmrc file. With this option set [npm](https://docs.npmjs.com/cli/v6/using-npm/config#always-auth)/yarn sends the authentication credentials when making a request to the registries.
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										48
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								src/main.ts
									
									
									
									
									
								
							@@ -40,17 +40,7 @@ export async function run() {
 | 
				
			|||||||
      await installer.getNode(version, stable, checkLatest, auth, arch);
 | 
					      await installer.getNode(version, stable, checkLatest, auth, arch);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Output version of node is being used
 | 
					    await printEnvDetailsAndSetOutput();
 | 
				
			||||||
    try {
 | 
					 | 
				
			||||||
      const {stdout: installedVersion} = await exec.getExecOutput(
 | 
					 | 
				
			||||||
        'node',
 | 
					 | 
				
			||||||
        ['--version'],
 | 
					 | 
				
			||||||
        {ignoreReturnCode: true, silent: true}
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      core.setOutput('node-version', installedVersion.trim());
 | 
					 | 
				
			||||||
    } catch (err) {
 | 
					 | 
				
			||||||
      core.setOutput('node-version', '');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const registryUrl: string = core.getInput('registry-url');
 | 
					    const registryUrl: string = core.getInput('registry-url');
 | 
				
			||||||
    const alwaysAuth: string = core.getInput('always-auth');
 | 
					    const alwaysAuth: string = core.getInput('always-auth');
 | 
				
			||||||
@@ -111,3 +101,39 @@ function resolveVersionInput(): string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return 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;
 | 
				
			||||||
 | 
					  } catch (err) {
 | 
				
			||||||
 | 
					    return '';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user