Util for optional/required inputs

This commit is contained in:
Marco Gario
2020-09-15 14:16:15 +02:00
parent 245c02cf7d
commit d5eefcf88f
15 changed files with 71 additions and 31 deletions
Generated
+21 -1
View File
@@ -215,7 +215,7 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
if (status === "success" || status === "failure" || status === "aborted") {
statusReport.completed_at = new Date().toISOString();
}
const matrix = core.getInput("matrix");
const matrix = getOptionalInput("matrix");
if (matrix) {
statusReport.matrix_vars = matrix;
}
@@ -383,4 +383,24 @@ function getCodeQLDatabasePath(tempDir, language) {
return path.resolve(getCodeQLDatabasesDir(tempDir), language);
}
exports.getCodeQLDatabasePath = getCodeQLDatabasePath;
/**
* Wrapper for core.getInput. Returns undefined if the requested
* input is not specified.
*/
function getOptionalInput(name) {
const value = core.getInput(name);
if (value === "") {
return undefined;
}
return value;
}
exports.getOptionalInput = getOptionalInput;
/**
* Wrapper for core.getInput. Returns the requested input or
* throws if not defined.
*/
function getRequiredInput(name) {
return core.getInput(name, { required: true });
}
exports.getRequiredInput = getRequiredInput;
//# sourceMappingURL=util.js.map