From 666ead3996603afe26bffd122efb95ac5cc34d66 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sat, 5 Nov 2022 18:09:11 +0100 Subject: main: fix -work flag I broke this flag in f866d5cc38319b1abcfd2e7302b2b8ed7d89cdad. This commit fixes it. --- main.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 4aaefd7c1..b34174850 100644 --- a/main.go +++ b/main.go @@ -160,7 +160,9 @@ func Build(pkgName, outpath string, options *compileopts.Options) error { if err != nil { return err } - defer os.RemoveAll(tmpdir) + if !options.Work { + defer os.RemoveAll(tmpdir) + } // Do the build. result, err := builder.Build(pkgName, outpath, tmpdir, config) @@ -405,7 +407,9 @@ func Flash(pkgName, port string, options *compileopts.Options) error { if err != nil { return err } - defer os.RemoveAll(tmpdir) + if !options.Work { + defer os.RemoveAll(tmpdir) + } // Build the binary. result, err := builder.Build(pkgName, fileExt, tmpdir, config) @@ -552,7 +556,9 @@ func Debug(debugger, pkgName string, ocdOutput bool, options *compileopts.Option if err != nil { return err } - defer os.RemoveAll(tmpdir) + if !options.Work { + defer os.RemoveAll(tmpdir) + } // Build the binary to debug. format, fileExt := config.EmulatorFormat() @@ -824,7 +830,9 @@ func buildAndRun(pkgName string, config *compileopts.Config, stdout io.Writer, c if err != nil { return err } - defer os.RemoveAll(tmpdir) + if !config.Options.Work { + defer os.RemoveAll(tmpdir) + } // Build the binary to be run. format, fileExt := config.EmulatorFormat() -- cgit v1.2.3