Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
feat: add a config validation function (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachieh authored Mar 7, 2020
1 parent 986aec1 commit d98ec8e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/shipit-deploy/src/extendShipit.js
Original file line number Diff line number Diff line change
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 d98ec8e

Please # to comment.