From ce23149e59d14050ad26bb7c33bd168e7edf38f2 Mon Sep 17 00:00:00 2001 From: BetaHuhn Date: Sun, 2 May 2021 13:11:07 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Check=20for=20undefined=20instea?= =?UTF-8?q?d=20of=20falsy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/index.js | 4 ++-- src/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 769eec3..decac27 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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; } diff --git a/src/index.ts b/src/index.ts index 8b5511c..4c6a9b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 }