Browse Source

Only throw when both `pkg.now` and `now.json` are present

Fixes failing test case.
master
Nathan Rajlich 8 years ago
parent
commit
7daf1e4c49
  1. 14
      lib/read-metadata.js

14
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 {

Loading…
Cancel
Save