diff --git a/src/dependencies.ts b/src/dependencies.ts index 63aa273..465144b 100644 --- a/src/dependencies.ts +++ b/src/dependencies.ts @@ -1,6 +1,6 @@ import * as core from '@actions/core' import {GRAALVM_PLATFORM} from './constants' -import {exec} from '@actions/exec' +import {exec} from './utils' const APT_GET_INSTALL_BASE = 'sudo apt-get -y --no-upgrade install' const COMPONENT_TO_DEPS = new Map>([ diff --git a/src/features.ts b/src/features.ts index 076adb8..e3b8a54 100644 --- a/src/features.ts +++ b/src/features.ts @@ -1,7 +1,7 @@ import * as core from '@actions/core' import * as tc from '@actions/tool-cache' import {IS_LINUX} from './constants' -import {exec} from '@actions/exec' +import {exec} from './utils' import {join} from 'path' const MUSL_NAME = 'x86_64-linux-musl-native' diff --git a/src/gu.ts b/src/gu.ts index b3004b2..552166d 100644 --- a/src/gu.ts +++ b/src/gu.ts @@ -1,5 +1,5 @@ import {GRAALVM_PLATFORM} from './constants' -import {exec} from '@actions/exec' +import {exec} from './utils' import {join} from 'path' const BASE_FLAGS = ['--non-interactive', 'install', '--no-progress'] diff --git a/src/utils.ts b/src/utils.ts index fefbf21..0ded275 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,6 +2,7 @@ import * as c from './constants' import * as core from '@actions/core' import * as httpClient from '@actions/http-client' import * as tc from '@actions/tool-cache' +import {ExecOptions, exec as e} from '@actions/exec' import {readFileSync, readdirSync} from 'fs' import {Octokit} from '@octokit/core' import {createHash} from 'crypto' @@ -16,6 +17,21 @@ const GitHub = Octokit.defaults({ } }) +export async function exec( + commandLine: string, + args?: string[], + options?: ExecOptions | undefined +): Promise { + const exitCode = await e(commandLine, args, options) + if (exitCode !== 0) { + throw new Error( + `'${[commandLine] + .concat(args || []) + .join(' ')}' exited with a non-zero code: ${exitCode}` + ) + } +} + export async function getLatestRelease( repo: string ): Promise {