Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case where the delimiter is preceeded by whitespace #125

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading