Skip to content

Commit

Permalink
Check for empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
zachkirsch committed Jan 11, 2023
1 parent f0003d7 commit 3425ae7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ async function run(): Promise<void> {

function getStringInputOrThrow(key: string): string {
const input: unknown = core.getInput(key);
if (input == null) {
if (input == null || isEmptyString(input)) {
throw new Error(`${key} is not defined.`);
}
if (typeof input !== "string") {
throw new Error(`${key} is not a string.`);
}
return input;
}

function isEmptyString(value: unknown): boolean {
return typeof value === "string" && value.length === 0;
}

0 comments on commit 3425ae7

Please sign in to comment.