Skip to content

Commit

Permalink
🐛 Check for undefined instead of falsy
Browse files Browse the repository at this point in the history
  • Loading branch information
BetaHuhn committed May 2, 2021
1 parent f40d15c commit ce23149
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ var getInput = function (key, opts) {
if (options.disableable && val === 'false')
return undefined;
var parsed = val !== undefined ? parseValue(val, options.type) : undefined;
if (!parsed) {
if (parsed === undefined) {
if (options.required)
throw new Error("Input `" + options.key + "` is required but was not provided.");
if (options.default)
if (options.default !== undefined)
return options.default;
return undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export const getInput = (key: string | IOpts, opts: IOpts): InputValue => {
if (options.disableable && val === 'false') return undefined

const parsed: InputValue = val !== undefined ? parseValue(val, options.type) : undefined
if (!parsed) {
if (parsed === undefined) {
if (options.required) throw new Error(`Input \`${ options.key }\` is required but was not provided.`)
if (options.default) return options.default
if (options.default !== undefined) return options.default

return undefined
}
Expand Down

0 comments on commit ce23149

Please sign in to comment.