Skip to content

Commit

Permalink
Merge pull request #125 from dokku/handle-whitespace
Browse files Browse the repository at this point in the history
feat: handle case where the delimiter is preceeded by whitespace
  • Loading branch information
josegonzalez authored Feb 11, 2024
2 parents 8d8ef3f + 3eb3ebe commit 4c04d6f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fixtures/comments.Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job)
cron: node worker.js
web: node web.js # testing inline comment
web : node web.js # testing inline comment
wor-ker: node worker.js
# -wor-ker2: node worker.js
# -wor-ker_2: node worker.js
Expand Down
4 changes: 2 additions & 2 deletions procfile/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func ParseFormation(formation string) (map[string]FormationEntry, error) {
// ParseProcfile parses text as a procfile and returns a list of procfile entries
func ParseProcfile(text string, delimiter string, strict bool) ([]ProcfileEntry, error) {
var entries []ProcfileEntry
reCmd, _ := regexp.Compile(`^([a-z0-9]([-a-z0-9]*[a-z0-9])?)` + delimiter + `\s*(.+)$`)
reOldCmd, _ := regexp.Compile(`^([A-Za-z0-9_-]+)` + delimiter + `\s*(.+)$`)
reCmd, _ := regexp.Compile(`^([a-z0-9]([-a-z0-9]*[a-z0-9])?)\s*` + delimiter + `\s*(.+)$`)
reOldCmd, _ := regexp.Compile(`^([A-Za-z0-9_-]+)\s*` + delimiter + `\s*(.+)$`)

reComment, _ := regexp.Compile(`^(.*)\s#.+$`)
reForwardslashComment, _ := regexp.Compile(`^(.*)\s//.+$`)
Expand Down
10 changes: 8 additions & 2 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ custom
release
web
wor-ker"

run $PROCFILE_BIN show -P fixtures/comments.Procfile -p web
echo "output: $output"
echo "status: $status"
[[ "$status" -eq 0 ]]
assert_output "node web.js"
}

@test "[lax] forwardslash-comments" {
Expand Down Expand Up @@ -183,8 +189,8 @@ flunk() {
assert_equal() {
if [[ "$1" != "$2" ]]; then
{
echo "expected: '$1'"
echo "actual: '$2'"
echo "expected: $1"
echo "actual: $2"
} | flunk
fi
}
Expand Down

0 comments on commit 4c04d6f

Please sign in to comment.