mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 08:33:33 +00:00 
			
		
		
		
	Format code and add try/catch blocks
This commit is contained in:
		
							parent
							
								
									6ba41b7436
								
							
						
					
					
						commit
						6599117e55
					
				@ -252,8 +252,16 @@ describe('setup-node', () => {
 | 
				
			|||||||
    let expPath = path.join(toolPath, 'bin');
 | 
					    let expPath = path.join(toolPath, 'bin');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(execExecSpy).toHaveBeenCalledWith('node', ['--version']);
 | 
					    expect(execExecSpy).toHaveBeenCalledWith('node', ['--version']);
 | 
				
			||||||
    expect(execExecSpy).toHaveBeenCalledWith('npm', ['--version'], expect.anything());
 | 
					    expect(execExecSpy).toHaveBeenCalledWith(
 | 
				
			||||||
    expect(execExecSpy).toHaveBeenCalledWith('yarn', ['--version'], expect.anything());
 | 
					      'npm',
 | 
				
			||||||
 | 
					      ['--version'],
 | 
				
			||||||
 | 
					      expect.anything()
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    expect(execExecSpy).toHaveBeenCalledWith(
 | 
				
			||||||
 | 
					      'yarn',
 | 
				
			||||||
 | 
					      ['--version'],
 | 
				
			||||||
 | 
					      expect.anything()
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(dlSpy).toHaveBeenCalled();
 | 
					    expect(dlSpy).toHaveBeenCalled();
 | 
				
			||||||
    expect(exSpy).toHaveBeenCalled();
 | 
					    expect(exSpy).toHaveBeenCalled();
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										24
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -71897,7 +71897,7 @@ function resolveVersionInput() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
function printEnvDetailsAndSetOutput() {
 | 
					function printEnvDetailsAndSetOutput() {
 | 
				
			||||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
        core.startGroup("Environment details");
 | 
					        core.startGroup('Environment details');
 | 
				
			||||||
        // Output version of node is being used
 | 
					        // Output version of node is being used
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            const { stdout: installedNodeVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true });
 | 
					            const { stdout: installedNodeVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true });
 | 
				
			||||||
@ -71906,12 +71906,22 @@ function printEnvDetailsAndSetOutput() {
 | 
				
			|||||||
        catch (err) {
 | 
					        catch (err) {
 | 
				
			||||||
            core.setOutput('node-version', '');
 | 
					            core.setOutput('node-version', '');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        yield exec.getExecOutput('npm', ['--version'], {
 | 
					        try {
 | 
				
			||||||
            ignoreReturnCode: true
 | 
					            yield exec.getExecOutput('npm', ['--version'], {
 | 
				
			||||||
        });
 | 
					                ignoreReturnCode: true
 | 
				
			||||||
        yield exec.getExecOutput('yarn', ['--version'], {
 | 
					            });
 | 
				
			||||||
            ignoreReturnCode: true
 | 
					        }
 | 
				
			||||||
        });
 | 
					        catch (_a) {
 | 
				
			||||||
 | 
					            core.warning('please check if npm is installed');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            yield exec.getExecOutput('yarn', ['--version'], {
 | 
				
			||||||
 | 
					                ignoreReturnCode: true
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (_b) {
 | 
				
			||||||
 | 
					            core.warning('please check if yarn is installed');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        core.endGroup();
 | 
					        core.endGroup();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										23
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/main.ts
									
									
									
									
									
								
							@ -100,7 +100,7 @@ function resolveVersionInput(): string {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function printEnvDetailsAndSetOutput() {
 | 
					async function printEnvDetailsAndSetOutput() {
 | 
				
			||||||
  core.startGroup("Environment details");
 | 
					  core.startGroup('Environment details');
 | 
				
			||||||
  // Output version of node is being used
 | 
					  // Output version of node is being used
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    const {stdout: installedNodeVersion} = await exec.getExecOutput(
 | 
					    const {stdout: installedNodeVersion} = await exec.getExecOutput(
 | 
				
			||||||
@ -112,14 +112,21 @@ async function printEnvDetailsAndSetOutput() {
 | 
				
			|||||||
  } catch (err) {
 | 
					  } catch (err) {
 | 
				
			||||||
    core.setOutput('node-version', '');
 | 
					    core.setOutput('node-version', '');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  try {
 | 
				
			||||||
 | 
					    await exec.getExecOutput('npm', ['--version'], {
 | 
				
			||||||
 | 
					      ignoreReturnCode: true
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  } catch {
 | 
				
			||||||
 | 
					    core.warning('please check if npm is installed');
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await exec.getExecOutput('npm', ['--version'], {
 | 
					  try {
 | 
				
			||||||
    ignoreReturnCode: true
 | 
					    await exec.getExecOutput('yarn', ['--version'], {
 | 
				
			||||||
  });
 | 
					      ignoreReturnCode: true
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
  await exec.getExecOutput('yarn', ['--version'], {
 | 
					  } catch {
 | 
				
			||||||
    ignoreReturnCode: true
 | 
					    core.warning('please check if yarn is installed');
 | 
				
			||||||
  });
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  core.endGroup();
 | 
					  core.endGroup();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user