make cleaning of target directory optional
This commit is contained in:
parent
3fccb1366a
commit
5fb684701f
15
goldsmith.go
15
goldsmith.go
@ -21,11 +21,13 @@ type Goldsmith struct {
|
||||
fileFilters []Filter
|
||||
fileCache *cache
|
||||
|
||||
clean bool
|
||||
|
||||
errors []error
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// Begin starts a chain, reading the files located in sourceDir as input.
|
||||
// Begin starts a chain, reading the files located in the source directory as input.
|
||||
func Begin(sourceDir string) *Goldsmith {
|
||||
goldsmith := &Goldsmith{
|
||||
sourceDir: sourceDir,
|
||||
@ -43,6 +45,12 @@ func (goldsmith *Goldsmith) Cache(cacheDir string) *Goldsmith {
|
||||
return goldsmith
|
||||
}
|
||||
|
||||
// Clean enables or disables removal of leftover files in the target directory.
|
||||
func (goldsmith *Goldsmith) Clean(clean bool) *Goldsmith {
|
||||
goldsmith.clean = clean
|
||||
return goldsmith
|
||||
}
|
||||
|
||||
// Chain links a plugin instance into the chain.
|
||||
func (goldsmith *Goldsmith) Chain(plugin Plugin) *Goldsmith {
|
||||
goldsmith.contextHasher.Write([]byte(plugin.Name()))
|
||||
@ -107,7 +115,10 @@ export:
|
||||
goldsmith.exportFile(file)
|
||||
}
|
||||
|
||||
goldsmith.removeUnreferencedFiles()
|
||||
if goldsmith.clean {
|
||||
goldsmith.removeUnreferencedFiles()
|
||||
}
|
||||
|
||||
return goldsmith.errors
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user