Add a cross process build lock and use it in the archetype content builder

Fixes #9048
This commit is contained in:
Bjørn Erik Pedersen 2021-10-17 11:54:55 +02:00
parent c7957c90e8
commit ba35e69856
7 changed files with 79 additions and 32 deletions

View file

@ -25,6 +25,18 @@ import (
"github.com/spf13/afero"
)
// IsTest reports whether we're running as a test.
var IsTest bool
func init() {
for _, arg := range os.Args {
if strings.HasPrefix(arg, "-test.") {
IsTest = true
break
}
}
}
// CreateTempDir creates a temp dir in the given filesystem and
// returns the dirnam and a func that removes it when done.
func CreateTempDir(fs afero.Fs, prefix string) (string, func(), error) {