diff --git a/dist/index.js b/dist/index.js index 1e2192b..226a511 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/src/index.ts b/src/index.ts index b6734f6..77c3088 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,12 +3,15 @@ import getInputs from './inputs' import setOutputs from './outputs' import install from './install' -const inputs = getInputs() +async function main() { + const inputs = await getInputs() + await install(inputs).then(() => { + console.log('Installation Completed!') + setOutputs(inputs) + }) +} -install(inputs).then(() => { - console.log('Installation Completed!') - setOutputs(inputs) -}).catch(error => { +main().catch(error => { console.error(error) setFailed(error) }) diff --git a/src/inputs/index.ts b/src/inputs/index.ts index c66aa2d..313fa50 100644 --- a/src/inputs/index.ts +++ b/src/inputs/index.ts @@ -1,4 +1,6 @@ -import { getInput, InputOptions } from '@actions/core' +import { inspect } from 'util' +import { getInput, error, InputOptions } from '@actions/core' +import * as glob from '@actions/glob' export interface Inputs { readonly version: string @@ -11,10 +13,21 @@ const options: InputOptions = { required: true, } -export const getInputs = (): Inputs => ({ +async function parsePath(pattern: string, inputName: string) { + const builder = await glob.create(pattern) + const paths = await builder.glob() + if (paths.length !== 1) { + error(`Input ${inputName} is expected to match 1 path, but it matches ${paths.length}: ${inspect(paths)}`) + } + return paths[0] +} + +const parseInputPath = (name: string) => parsePath(getInput(name, options), name) + +export const getInputs = async (): Promise => ({ version: getInput('version', options), - dest: getInput('dest', options), - binDest: getInput('bin_dest', options), + dest: await parseInputPath('dest'), + binDest: await parseInputPath('bin_dest'), registry: getInput('registry', options), })