respect a 'only' defined in a post-processor

This commit is contained in:
Adrien Delorme 2019-02-01 15:50:06 +01:00
parent 074a74ec38
commit dd3e2c255c
2 changed files with 9 additions and 7 deletions

View File

@ -108,7 +108,7 @@ func TestBuildExceptFileCommaFlags(t *testing.T) {
}
args := []string{
"-except=chocolate,apple",
"-except=chocolate,vanilla",
filepath.Join(testFixture("build-only"), "template.json"),
}
@ -118,12 +118,12 @@ func TestBuildExceptFileCommaFlags(t *testing.T) {
fatalCommand(t, c.Meta)
}
for _, f := range []string{"chocolate.txt", "apple.txt"} {
for _, f := range []string{"chocolate.txt", "vanilla.txt", "tomato.txt"} {
if fileExists(f) {
t.Errorf("Expected NOT to find %s", f)
}
}
for _, f := range []string{"vanilla.txt", "cherry.txt", "pear.txt", "peach.txt"} {
for _, f := range []string{"apple.txt", "cherry.txt", "pear.txt", "peach.txt"} {
if !fileExists(f) {
t.Errorf("Expected to find %s", f)
}

View File

@ -180,11 +180,13 @@ func (c *Core) Build(n string) (Build, error) {
for _, rawPs := range c.Template.PostProcessors {
current := make([]coreBuildPostProcessor, 0, len(rawPs))
for _, rawP := range rawPs {
// If we skip, ignore
if rawP.Skip(rawName) {
continue
}
// -except skips post-processor & build
foundExcept := false
excepts := append(rawP.OnlyExcept.Except, c.except...)
for _, except := range excepts {
if except == rawName || except == rawP.Name {
for _, except := range c.except {
if except == rawP.Name {
foundExcept = true
}
}