Explicitly prevent instance reuse
This commit is contained in:
parent
f20984e6f0
commit
434e755419
11
core.go
11
core.go
@ -32,6 +32,7 @@ type goldsmith struct {
|
|||||||
srcDir, dstDir string
|
srcDir, dstDir string
|
||||||
contexts []*context
|
contexts []*context
|
||||||
refs map[string]bool
|
refs map[string]bool
|
||||||
|
complete bool
|
||||||
|
|
||||||
errors []error
|
errors []error
|
||||||
errorMtx sync.Mutex
|
errorMtx sync.Mutex
|
||||||
@ -102,11 +103,19 @@ func (gs *goldsmith) fault(name string, f *file, err error) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
func (gs *goldsmith) Chain(p Plugin, filters ...string) Goldsmith {
|
func (gs *goldsmith) Chain(p Plugin, filters ...string) Goldsmith {
|
||||||
|
if gs.complete {
|
||||||
|
panic("attempted reuse of goldsmith instance")
|
||||||
|
}
|
||||||
|
|
||||||
gs.pushContext(p, filters)
|
gs.pushContext(p, filters)
|
||||||
return gs
|
return gs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gs *goldsmith) End(dstDir string) []error {
|
func (gs *goldsmith) End(dstDir string) []error {
|
||||||
|
if gs.complete {
|
||||||
|
panic("attempted reuse of goldsmith instance")
|
||||||
|
}
|
||||||
|
|
||||||
gs.dstDir = dstDir
|
gs.dstDir = dstDir
|
||||||
|
|
||||||
for _, ctx := range gs.contexts {
|
for _, ctx := range gs.contexts {
|
||||||
@ -119,5 +128,7 @@ func (gs *goldsmith) End(dstDir string) []error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gs.cleanupFiles()
|
gs.cleanupFiles()
|
||||||
|
gs.complete = true
|
||||||
|
|
||||||
return gs.errors
|
return gs.errors
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user