@@ -28,7 +28,6 @@ import (
28
28
"github.com/arduino/arduino-cli/commands/upload"
29
29
"github.com/arduino/arduino-cli/i18n"
30
30
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
31
- "github.com/arduino/go-paths-helper"
32
31
"github.com/spf13/cobra"
33
32
)
34
33
@@ -82,28 +81,22 @@ func run(command *cobra.Command, args []string) {
82
81
if len (args ) > 0 {
83
82
path = args [0 ]
84
83
}
85
- var sketchPath * paths.Path
86
- var sk * sketch.Sketch = nil
87
- // If the user explicitly specified a directory that contains binaries to upload
88
- // use those, we don't really need a valid Sketch to upload in this case
89
- if importDir == "" && importFile == "" {
90
- sketchPath = arguments .InitSketchPath (path )
91
-
92
- // .pde files are still supported but deprecated, this warning urges the user to rename them
93
- if files := sketch .CheckForPdeFiles (sketchPath ); len (files ) > 0 {
94
- feedback .Error (tr ("Sketches with .pde extension are deprecated, please rename the following files to .ino:" ))
95
- for _ , f := range files {
96
- feedback .Error (f )
97
- }
98
- }
84
+ sketchPath := arguments .InitSketchPath (path )
99
85
100
- var err error
101
- sk , err = sketch .New (sketchPath )
102
- if err != nil {
103
- feedback . Errorf ( tr ( "Error during Upload: %v" ), err )
104
- os . Exit ( errorcodes . ErrGeneric )
86
+ // .pde files are still supported but deprecated, this warning urges the user to rename them
87
+ if files : = sketch .CheckForPdeFiles (sketchPath ); len ( files ) > 0 && importDir == "" && importFile == "" {
88
+ feedback . Error ( tr ( "Sketches with .pde extension are deprecated, please rename the following files to .ino:" ))
89
+ for _ , f := range files {
90
+ feedback . Error ( f )
105
91
}
106
92
}
93
+
94
+ sk , err := sketch .New (sketchPath )
95
+ if err != nil && importDir == "" && importFile == "" {
96
+ feedback .Errorf (tr ("Error during Upload: %v" ), err )
97
+ os .Exit (errorcodes .ErrGeneric )
98
+ }
99
+
107
100
discoveryPort , err := port .GetPort (instance , sk )
108
101
if err != nil {
109
102
feedback .Errorf (tr ("Error during Upload: %v" ), err )
0 commit comments