Skip to content

Commit

Permalink
feat: add a config validation function (shipitjs#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachieh authored and oleg-andreyev committed Mar 11, 2020
1 parent 3c8bb8b commit e489025
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/shipit-deploy/src/extendShipit.js
Expand Up @@ -42,8 +42,22 @@ function computeReleaseDirname(result) {
return target.split(path.sep).pop()
}

function validateConfig(config) {
const errors = []
if (!config.deployTo) {
errors.push("Config must include a 'deployTo' property")
}
if (errors.length) {
console.log(errors)
throw new Error(
'Config is invalid. Please refer to errors above and try again.',
)
}
}

function extendShipit(shipit) {
/* eslint-disable no-param-reassign */
validateConfig(shipit.config)
shipit.currentPath = path.join(shipit.config.deployTo, 'current')
shipit.releasesPath = path.join(shipit.config.deployTo, 'releases')
const config = {
Expand Down

0 comments on commit e489025

Please sign in to comment.