Browse Source

add a `strict` mode to readMetadata()

Test cases will set this to `false`, because they're
missing `scripts.start` and other required properties in this function
master
Nathan Rajlich 8 years ago
parent
commit
cee788d3e1
  1. 5
      lib/read-metadata.js

5
lib/read-metadata.js

@ -16,6 +16,7 @@ module.exports = async function (path, {
deploymentType = 'npm', deploymentType = 'npm',
deploymentName, deploymentName,
quiet = false, quiet = false,
strict = true,
isStatic = false isStatic = false
}) { }) {
let pkg = {} let pkg = {}
@ -50,7 +51,7 @@ module.exports = async function (path, {
} }
} }
if (!pkg.scripts || (!pkg.scripts.start && !pkg.scripts['now-start'])) { if (strict && (!pkg.scripts || (!pkg.scripts.start && !pkg.scripts['now-start']))) {
const e = Error('Missing `start` (or `now-start`) script in `package.json`. ' + const e = Error('Missing `start` (or `now-start`) script in `package.json`. ' +
'See: https://docs.npmjs.com/cli/start.') 'See: https://docs.npmjs.com/cli/start.')
e.userError = true e.userError = true
@ -81,7 +82,7 @@ module.exports = async function (path, {
throw e throw e
} }
if (docker.length <= 0) { if (strict && docker.length <= 0) {
const e = Error('No commands found in `Dockerfile`') const e = Error('No commands found in `Dockerfile`')
e.userError = true e.userError = true
throw e throw e

Loading…
Cancel
Save