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

Commit d98ec8e

Browse files
authored
feat: add a config validation function (#258)
1 parent 986aec1 commit d98ec8e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/shipit-deploy/src/extendShipit.js

+14
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,22 @@ function computeReleaseDirname(result) {
4242
return target.split(path.sep).pop()
4343
}
4444

45+
function validateConfig(config) {
46+
const errors = []
47+
if (!config.deployTo) {
48+
errors.push("Config must include a 'deployTo' property")
49+
}
50+
if (errors.length) {
51+
console.log(errors)
52+
throw new Error(
53+
'Config is invalid. Please refer to errors above and try again.',
54+
)
55+
}
56+
}
57+
4558
function extendShipit(shipit) {
4659
/* eslint-disable no-param-reassign */
60+
validateConfig(shipit.config)
4761
shipit.currentPath = path.join(shipit.config.deployTo, 'current')
4862
shipit.releasesPath = path.join(shipit.config.deployTo, 'releases')
4963
const config = {

0 commit comments

Comments
 (0)