Skip to content

Commit 203fd0d

Browse files
author
Matthew Fisher
committed
Merge pull request #47 from Joshua-Anderson/config-comments
feat(config): ignore comments in config:push
2 parents ee40d59 + ce6e64c commit 203fd0d

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

cmd/config.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,28 @@ func ConfigPush(appID, fileName string) error {
239239
}
240240
}
241241

242-
config := strings.Split(string(contents), "\n")
243-
return ConfigSet(appID, config[:len(config)-1])
242+
file := strings.Split(string(contents), "\n")
243+
config := []string{}
244+
245+
for _, configVar := range file {
246+
if len(configVar) > 0 {
247+
config = append(config, configVar)
248+
}
249+
}
250+
251+
return ConfigSet(appID, config)
244252
}
245253

246254
func parseConfig(configVars []string) map[string]interface{} {
247255
configMap := make(map[string]interface{})
248256

249257
regex := regexp.MustCompile(`^([A-z_]+[A-z0-9_]*)=([\s\S]+)$`)
250258
for _, config := range configVars {
259+
// Skip config that starts with an comment
260+
if config[0] == '#' {
261+
continue
262+
}
263+
251264
if regex.MatchString(config) {
252265
captures := regex.FindStringSubmatch(config)
253266
configMap[captures[1]] = captures[2]

0 commit comments

Comments
 (0)