Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error only if exit code is no zero. #358

Merged
merged 6 commits into from Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/licensed.yml
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install licensed
run: |
cd $RUNNER_TEMP
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.3.1/licensed-3.3.1-linux-x64.tar.gz
sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed
- run: licensed status
7 changes: 5 additions & 2 deletions dist/cache-save/index.js
Expand Up @@ -3836,8 +3836,11 @@ exports.supportedPackageManagers = {
}
};
exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand);
if (stderr) {
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
if (exitCode) {
stderr = !stderr
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
: stderr;
throw new Error(stderr);
}
return stdout.trim();
Expand Down
7 changes: 5 additions & 2 deletions dist/setup/index.js
Expand Up @@ -46207,8 +46207,11 @@ exports.supportedPackageManagers = {
}
};
exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand);
if (stderr) {
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
if (exitCode) {
stderr = !stderr
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
: stderr;
throw new Error(stderr);
}
return stdout.trim();
Expand Down
11 changes: 9 additions & 2 deletions src/cache-utils.ts
Expand Up @@ -30,9 +30,16 @@ export const supportedPackageManagers: SupportedPackageManagers = {
};

export const getCommandOutput = async (toolCommand: string) => {
const {stdout, stderr, exitCode} = await exec.getExecOutput(toolCommand);
let {stdout, stderr, exitCode} = await exec.getExecOutput(
toolCommand,
undefined,
{ignoreReturnCode: true}
);

if (stderr) {
if (exitCode) {
stderr = !stderr
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
: stderr;
throw new Error(stderr);
}

Expand Down