Commit 245deaf5 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

buidler/virtualbox,vmware: only stat if not force

/cc @jasonberanek - Swapped this because why even bother doing a stat
if we're forcing anyways.
parent 276428a3
......@@ -219,9 +219,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
}
if _, err := os.Stat(b.config.OutputDir); err == nil {
if !b.config.PackerForce {
errs = append(errs, errors.New("Output directory already exists. It must not exist."))
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."))
}
}
......
......@@ -175,9 +175,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
}
if _, err := os.Stat(b.config.OutputDir); err == nil {
if !b.config.PackerForce {
errs = append(errs, errors.New("Output directory already exists. It must not exist."))
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."))
}
}
......
......@@ -15,7 +15,7 @@ func (stepPrepareOutputDir) Run(state map[string]interface{}) multistep.StepActi
if _, err := os.Stat(config.OutputDir); err == nil && config.PackerForce {
ui.Say("Deleting previous output directory...")
os.RemoveAll(config.OutputDir)
}
}
if err := os.MkdirAll(config.OutputDir, 0755); err != nil {
state["error"] = err
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment