buidler/virtualbox,vmware: only stat if not force
/cc @jasonberanek - Swapped this because why even bother doing a stat if we're forcing anyways.
This commit is contained in:
parent
276428a330
commit
245deaf599
|
@ -219,9 +219,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(b.config.OutputDir); err == nil {
|
if !b.config.PackerForce {
|
||||||
if !b.config.PackerForce {
|
if _, err := os.Stat(b.config.OutputDir); err == nil {
|
||||||
errs = append(errs, errors.New("Output directory already exists. It must not exist."))
|
errs = append(
|
||||||
|
errs,
|
||||||
|
errors.New("Output directory already exists. It must not exist."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,9 +175,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(b.config.OutputDir); err == nil {
|
if !b.config.PackerForce {
|
||||||
if !b.config.PackerForce {
|
if _, err := os.Stat(b.config.OutputDir); err == nil {
|
||||||
errs = append(errs, errors.New("Output directory already exists. It must not exist."))
|
errs = append(
|
||||||
|
errs,
|
||||||
|
errors.New("Output directory already exists. It must not exist."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ func (stepPrepareOutputDir) Run(state map[string]interface{}) multistep.StepActi
|
||||||
if _, err := os.Stat(config.OutputDir); err == nil && config.PackerForce {
|
if _, err := os.Stat(config.OutputDir); err == nil && config.PackerForce {
|
||||||
ui.Say("Deleting previous output directory...")
|
ui.Say("Deleting previous output directory...")
|
||||||
os.RemoveAll(config.OutputDir)
|
os.RemoveAll(config.OutputDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.MkdirAll(config.OutputDir, 0755); err != nil {
|
if err := os.MkdirAll(config.OutputDir, 0755); err != nil {
|
||||||
state["error"] = err
|
state["error"] = err
|
||||||
|
|
Loading…
Reference in New Issue