diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index ee3ede79..829ee1f3 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -252,8 +252,16 @@ describe('setup-node', () => { let expPath = path.join(toolPath, 'bin'); expect(execExecSpy).toHaveBeenCalledWith('node', ['--version']); - expect(execExecSpy).toHaveBeenCalledWith('npm', ['--version'], expect.anything()); - expect(execExecSpy).toHaveBeenCalledWith('yarn', ['--version'], expect.anything()); + expect(execExecSpy).toHaveBeenCalledWith( + 'npm', + ['--version'], + expect.anything() + ); + expect(execExecSpy).toHaveBeenCalledWith( + 'yarn', + ['--version'], + expect.anything() + ); expect(dlSpy).toHaveBeenCalled(); expect(exSpy).toHaveBeenCalled(); diff --git a/dist/setup/index.js b/dist/setup/index.js index aa232692..c6817cce 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -71897,7 +71897,7 @@ function resolveVersionInput() { } function printEnvDetailsAndSetOutput() { return __awaiter(this, void 0, void 0, function* () { - core.startGroup("Environment details"); + core.startGroup('Environment details'); // Output version of node is being used try { const { stdout: installedNodeVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true }); @@ -71906,12 +71906,22 @@ function printEnvDetailsAndSetOutput() { catch (err) { core.setOutput('node-version', ''); } - yield exec.getExecOutput('npm', ['--version'], { - ignoreReturnCode: true - }); - yield exec.getExecOutput('yarn', ['--version'], { - ignoreReturnCode: true - }); + try { + yield exec.getExecOutput('npm', ['--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(); }); } diff --git a/src/main.ts b/src/main.ts index 09c09e6a..3ef17c99 100644 --- a/src/main.ts +++ b/src/main.ts @@ -100,7 +100,7 @@ function resolveVersionInput(): string { } async function printEnvDetailsAndSetOutput() { - core.startGroup("Environment details"); + core.startGroup('Environment details'); // Output version of node is being used try { const {stdout: installedNodeVersion} = await exec.getExecOutput( @@ -112,14 +112,21 @@ async function printEnvDetailsAndSetOutput() { } catch (err) { 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'], { - ignoreReturnCode: true - }); - - await exec.getExecOutput('yarn', ['--version'], { - ignoreReturnCode: true - }); + try { + await exec.getExecOutput('yarn', ['--version'], { + ignoreReturnCode: true + }); + } catch { + core.warning('please check if yarn is installed'); + } core.endGroup(); }