Skip to content

Commit

Permalink
fix: handle no matching path gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
btkostner authored Aug 20, 2021
1 parent ef45ede commit 5946055
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 () => {
Expand Down

0 comments on commit 5946055

Please sign in to comment.