Skip to content

Commit

Permalink
don't fail if both Command and Entrypoint are empty
Browse files Browse the repository at this point in the history
this would be a breaking change as empty command was previously
allowed

also: log warning about both Command and Entrypoint being set
to stderr to not interfere with downstream consumers of stdout
  • Loading branch information
adrian-gierakowski committed Nov 12, 2023
1 parent 33eef85 commit d787b8b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/types/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/f1bonacc1/process-compose/src/command"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"os"
"strings"
)

Expand Down Expand Up @@ -80,10 +81,10 @@ func (p *Project) validateProcessCommand() {
command := proc.Command
entrypoint := proc.Entrypoint

if command != "" {
if command != "" || len(entrypoint) == 0 {
if len(entrypoint) > 0 {
message := fmt.Sprintf("Both command and entrypoint are set! Using command and ignoring entrypoint (procces: %s)", name)
fmt.Println(message)
fmt.Fprintln(os.Stderr, "process-compose:", message)
log.Error().Msg(message)
}

Expand All @@ -92,13 +93,9 @@ func (p *Project) validateProcessCommand() {
p.ShellConfig.ShellArgument,
command,
}
} else if len(entrypoint) > 0 {
} else {
proc.Executable = entrypoint[0]
proc.Args = entrypoint[1:]
} else {
message := fmt.Sprintf("Either command or entrypoint need to be non-empty (procces: %s)", name)
fmt.Println(message)
log.Fatal().Msg(message)
}

p.Processes[name] = proc
Expand Down

0 comments on commit d787b8b

Please sign in to comment.