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
|
fileFilters []Filter
|
||||||
fileCache *cache
|
fileCache *cache
|
||||||
|
|
||||||
|
clean bool
|
||||||
|
|
||||||
errors []error
|
errors []error
|
||||||
mutex sync.Mutex
|
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 {
|
func Begin(sourceDir string) *Goldsmith {
|
||||||
goldsmith := &Goldsmith{
|
goldsmith := &Goldsmith{
|
||||||
sourceDir: sourceDir,
|
sourceDir: sourceDir,
|
||||||
@ -43,6 +45,12 @@ func (goldsmith *Goldsmith) Cache(cacheDir string) *Goldsmith {
|
|||||||
return 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.
|
// Chain links a plugin instance into the chain.
|
||||||
func (goldsmith *Goldsmith) Chain(plugin Plugin) *Goldsmith {
|
func (goldsmith *Goldsmith) Chain(plugin Plugin) *Goldsmith {
|
||||||
goldsmith.contextHasher.Write([]byte(plugin.Name()))
|
goldsmith.contextHasher.Write([]byte(plugin.Name()))
|
||||||
@ -107,7 +115,10 @@ export:
|
|||||||
goldsmith.exportFile(file)
|
goldsmith.exportFile(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
goldsmith.removeUnreferencedFiles()
|
if goldsmith.clean {
|
||||||
|
goldsmith.removeUnreferencedFiles()
|
||||||
|
}
|
||||||
|
|
||||||
return goldsmith.errors
|
return goldsmith.errors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user