From 59460559c25aa84244881a52218c086b967d9420 Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Fri, 20 Aug 2021 14:42:05 -0600 Subject: [PATCH] fix: handle no matching path gracefully --- src/index.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/index.js b/src/index.js index f8f5d49..fcd6d2f 100644 --- a/src/index.js +++ b/src/index.js @@ -57,13 +57,14 @@ async function getChangedFile () { if (matchingFiles.length > 1) { core.setFailed('Multiple matching files found') + return null } else if (matchingFiles.length < 1) { core.setFailed('No matching files found') + return null + } else { + core.info(`Selecting ${matchingFiles[0]}`) + return matchingFiles[0] } - - core.info(`Selecting ${matchingFiles[0]}`) - - return matchingFiles[0] } async function fileData (filePath) { @@ -81,18 +82,21 @@ async function fileData (filePath) { async function run () { const filePath = await getChangedFile() - const { rdnn, version, source, commit } = await fileData(filePath) - - core.info('Found this information:') - core.info(`RDNN: ${rdnn}`) - core.info(`Version: ${version}`) - core.info(`Source: ${source}`) - core.info(`Commit: ${commit}`) - - core.setOutput('rdnn', rdnn) - core.setOutput('version', version) - core.setOutput('source', source) - core.setOutput('commit', commit) + + if (filePath != null) { + const { rdnn, version, source, commit } = await fileData(filePath) + + core.info('Found this information:') + core.info(`RDNN: ${rdnn}`) + core.info(`Version: ${version}`) + core.info(`Source: ${source}`) + core.info(`Commit: ${commit}`) + + core.setOutput('rdnn', rdnn) + core.setOutput('version', version) + core.setOutput('source', source) + core.setOutput('commit', commit) + } } ;(async () => {