Skip to content

Commit d00ba76

Browse files
committed
fix: getInputFromEnv could return empty string
1 parent 0c57458 commit d00ba76

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

dist/index.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/input.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
2+
13
// https://github.com/actions/toolkit/blob/27f76dfe1afb2b7e5e679cd8e97192d34d8320e6/packages/core/src/core.ts#L128
24
function getInputFromEnv(name: string, options: { required: true }): string
35
function getInputFromEnv(
@@ -10,10 +12,10 @@ function getInputFromEnv(
1012
): string | undefined {
1113
const value = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`]
1214
const { required = false } = options
13-
if (required && value === undefined) {
15+
if (required && !value) {
1416
throw new Error(`Input required and not supplied: ${name}`)
1517
}
16-
return value?.trim()
18+
return !value ? undefined : value.trim()
1719
}
1820

1921
type Input = Readonly<{

0 commit comments

Comments
 (0)