@@ -21,15 +21,18 @@ import (
21
21
22
22
"github.com/arduino/arduino-cli/legacy/builder/builder_utils"
23
23
"github.com/arduino/arduino-cli/legacy/builder/constants"
24
- "github.com/arduino/arduino-cli/legacy/builder/gohasissues"
25
24
"github.com/arduino/arduino-cli/legacy/builder/types"
25
+ "github.com/arduino/go-paths-helper"
26
26
properties "github.com/arduino/go-properties-orderedmap"
27
27
"github.com/pkg/errors"
28
28
)
29
29
30
30
type WipeoutBuildPathIfBuildOptionsChanged struct {}
31
31
32
32
func (s * WipeoutBuildPathIfBuildOptionsChanged ) Run (ctx * types.Context ) error {
33
+ if ctx .Clean {
34
+ return doCleanup (ctx .BuildPath )
35
+ }
33
36
if ctx .BuildOptionsJsonPrevious == "" {
34
37
return nil
35
38
}
@@ -64,18 +67,22 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(ctx *types.Context) error {
64
67
}
65
68
}
66
69
70
+ return doCleanup (ctx .BuildPath )
71
+ }
72
+
73
+ func doCleanup (buildPath * paths.Path ) error {
67
74
// FIXME: this should go outside legacy and behind a `logrus` call so users can
68
75
// control when this should be printed.
69
76
// logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_BUILD_OPTIONS_CHANGED)
70
77
71
- buildPath := ctx .BuildPath
72
- files , err := gohasissues .ReadDir (buildPath .String ())
73
- if err != nil {
74
- return errors .WithStack (err )
75
- }
76
- for _ , file := range files {
77
- buildPath .Join (file .Name ()).RemoveAll ()
78
+ if files , err := buildPath .ReadDir (); err != nil {
79
+ return errors .WithMessage (err , "cleaning build path" )
80
+ } else {
81
+ for _ , file := range files {
82
+ if err := file .RemoveAll (); err != nil {
83
+ return errors .WithMessage (err , "cleaning build path" )
84
+ }
85
+ }
78
86
}
79
-
80
87
return nil
81
88
}
0 commit comments