Skip to content

Commit

Permalink
fix: allow to provide $ sign in ENV expanded hook definitions
Browse files Browse the repository at this point in the history
RaVbaker committed May 27, 2021

Verified

This commit was signed with the committer’s verified signature.
TimothyWillard Timothy Willard
1 parent 3bbfa1e commit 344be5f
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ hooks:
assume_role: "arn:aws:iam::123456789012:role/LambdaRunner"
function_name: "my-${USER}-lambda"
region: "us-east-1"
payload: "{}"
payload: "{\"some\": \"$$ will be dollar sign while $@ or ${PATH} will get replaced from the runtime\"}"
```
## Makefile
4 changes: 3 additions & 1 deletion internal/hooks/hook.go
Original file line number Diff line number Diff line change
@@ -118,5 +118,7 @@ func (h *Hook) Definition() Spec {

func templateString(path, template string) string {
template = strings.ReplaceAll(template, "{path}", path)
return os.ExpandEnv(template)
template = strings.ReplaceAll(template, "$$", "$&&")
template = os.ExpandEnv(template)
return strings.ReplaceAll(template, "$&&", "$")
}

0 comments on commit 344be5f

Please sign in to comment.