Skip to content

Commit

Permalink
feat: check source file extension name
Browse files Browse the repository at this point in the history
The source file extension name should be one of .zip, .tar.gz, .tgz, or
.tar.bz2.
  • Loading branch information
wdzeng committed Aug 16, 2024
1 parent 7a3a2a6 commit 2844b7e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ function requireValidXpiExtensionName(xpiPath: string) {
}
}

function requireValidSourceFileExtensionName(f: string) {
if (f.endsWith('.zip') || f.endsWith('.tar.gz') || f.endsWith('.tgz') || f.endsWith('.tar.bz2')) {
return
}
core.setFailed(
'Input "source-file-path" must have a valid extension name (.zip, .tar.gz, .tgz, .tar.bz2).'
)
core.debug(`source-file-path: ${f}`)
process.exit(ERR_INVALID_INPUT)
}

async function run(
addonGuid: string,
license: string | undefined,
Expand Down Expand Up @@ -94,6 +105,9 @@ async function main() {
const jwtIssuer = core.getInput('jwt-issuer', { required: true })
const jwtSecret = core.getInput('jwt-secret', { required: true })
const sourceFilePath = core.getInput('source-file-path', { required: false }) || undefined
if (sourceFilePath) {
requireValidSourceFileExtensionName(sourceFilePath)
}

try {
await run(
Expand Down

0 comments on commit 2844b7e

Please sign in to comment.