From 6d83be5f25507701fec8f345af9051d194284e69 Mon Sep 17 00:00:00 2001 From: Olli Vanhoja Date: Sat, 29 Oct 2016 00:50:52 +0300 Subject: [PATCH] Now deploy env fixes (#105) * Fix key and value checks - key can't be empty string nor undefined or null - value is always undefined if it's not set * Fix crash if env key and value are missing when using -e --- bin/now-deploy.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/now-deploy.js b/bin/now-deploy.js index c005389..733f6d1 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -306,6 +306,10 @@ async function sync(token) { } const env_ = await Promise.all(envs.map(async kv => { + if (typeof kv !== 'string') { + error('Env key and value missing') + return process.exit(1) + } const [key, ...rest] = kv.split('=') let val @@ -318,12 +322,12 @@ async function sync(token) { return process.exit(1) } - if (key === '' || key === null) { + if (!key) { error(`Invalid env option ${chalk.bold(`"${kv}"`)}`) return process.exit(1) } - if (val === null) { + if (val === undefined) { if ((key in process.env)) { console.log(`> Reading ${chalk.bold(`"${chalk.bold(key)}"`)} from your env (as no value was specified)`) // escape value if it begins with @