Refactor input parameters

Moved reading of all input parameters into a common source: `input-params.ts`.
This centralized all input parameter reads, and allowed an improved implementation
of reading boolean parameters. In particular, the implementation now provides a default
value for a boolean input parameter that isn't declared for an action.
This commit is contained in:
daz
2023-06-03 15:58:54 -06:00
parent c94d573317
commit 07023d3e3e
8 changed files with 102 additions and 42 deletions

View File

@@ -1,10 +1,10 @@
import * as core from '@actions/core'
import {parseArgsStringToArgv} from 'string-argv'
import * as setupGradle from './setup-gradle'
import * as execution from './execution'
import * as provisioner from './provision'
import * as layout from './repository-layout'
import * as params from './input-params'
/**
* The main entry point for the action, called by Github Actions for the step.
@@ -18,7 +18,7 @@ export async function run(): Promise<void> {
const executable = await provisioner.provisionGradle()
// Only execute if arguments have been provided
const args: string[] = parseCommandLineArguments()
const args: string[] = params.getArguments()
if (args.length > 0) {
const buildRootDirectory = layout.buildRootDirectory()
await execution.executeGradleBuild(executable, buildRootDirectory, args)
@@ -32,8 +32,3 @@ export async function run(): Promise<void> {
}
run()
function parseCommandLineArguments(): string[] {
const input = core.getInput('arguments')
return parseArgsStringToArgv(input)
}