From 7daf1e4c492d3cd29de45106f19a3f190a05852b Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 25 Jan 2017 10:42:45 -0800 Subject: [PATCH] Only throw when both `pkg.now` and `now.json` are present Fixes failing test case. --- lib/read-metadata.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/read-metadata.js b/lib/read-metadata.js index 529221f..8b19b60 100644 --- a/lib/read-metadata.js +++ b/lib/read-metadata.js @@ -23,12 +23,14 @@ async function readMetaData(path, { }) { let pkg = {} let nowConfig = {} + let hasNowJson = false let name let description try { nowConfig = JSON.parse(await readFile(resolvePath(path, 'now.json'))) + hasNowJson = true } catch (err) { // if the file doesn't exist then that's fine; any other error bubbles up if (err.code !== 'ENOENT') { @@ -127,11 +129,15 @@ async function readMetaData(path, { name = deploymentName } - // if the project has both a `now.json` and `now` Object in the `package.json` - // file, then fail hard and let the user know that they need to pick one or the - // other if (pkg.now) { - throw new Error('Refusing to proceed with multiple Now configurations (`now.json` and `package.json`). Please pick only one, then try again!') + // if the project has both a `now.json` and `now` Object in the `package.json` + // file, then fail hard and let the user know that they need to pick one or the + // other + if (hasNowJson) { + throw new Error('Refusing to proceed with multiple Now configurations (`now.json` and `package.json`). Please pick only one, then try again!') + } else { + nowConfig = pkg.now + } } return {