Skip to content
Permalink
Browse files

add the ability to override .proxy.command at the stage level

  • Loading branch information...
tj committed Jan 27, 2018
1 parent 749a62f commit 973a5299f42da6e5ca38519cf2f3c2ea8f717cba
Showing with 18 additions and 0 deletions.
  1. +7 −0 config/relay.go
  2. +2 −0 config/stages.go
  3. +8 −0 config/stages_test.go
  4. +1 −0 docs/04-configuration.md
@@ -99,3 +99,10 @@ func (r *Relay) Validate() error {

return nil
}

// Override config.
func (r *Relay) Override(c *Config) {
if r.Command != "" {
c.Proxy.Command = r.Command
}
}
@@ -13,12 +13,14 @@ type Stage struct {
type StageOverrides struct {
Hooks Hooks `json:"hooks"`
Lambda Lambda `json:"lambda"`
Proxy Relay `json:"proxy"`
}

// Override config.
func (s *StageOverrides) Override(c *Config) {
s.Hooks.Override(c)
s.Lambda.Override(c)
s.Proxy.Override(c)
}

// Stages config.
@@ -17,6 +17,9 @@ func TestStage_Override(t *testing.T) {
Build: Hook{"parcel index.html -o build"},
Clean: Hook{"rm -fr clean"},
},
Proxy: Relay{
Command: "./server",
},
}

t.Run("with no overrides", func(t *testing.T) {
@@ -34,6 +37,7 @@ func TestStage_Override(t *testing.T) {

assert.Equal(t, "parcel index.html -o build", c.Hooks.Build[0])
assert.Equal(t, "rm -fr clean", c.Hooks.Clean[0])
assert.Equal(t, `./server`, c.Proxy.Command)
})

t.Run("with overrides", func(t *testing.T) {
@@ -49,6 +53,9 @@ func TestStage_Override(t *testing.T) {
Lambda: Lambda{
Memory: 1024,
},
Proxy: Relay{
Command: "./server --foo",
},
},
}

@@ -60,6 +67,7 @@ func TestStage_Override(t *testing.T) {
assert.Equal(t, "parcel index.html -o build --production", c.Hooks.Build[0])
assert.Equal(t, "do something", c.Hooks.PostBuild[0])
assert.Equal(t, "rm -fr clean", c.Hooks.Clean[0])
assert.Equal(t, `./server --foo`, c.Proxy.Command)
})
}

@@ -631,6 +631,7 @@ Currently the following properties may be specified at the stage level:

- `hooks`
- `lambda`
- `proxy.command`

## Ignoring Files

0 comments on commit 973a529

Please sign in to comment.
You can’t perform that action at this time.