Skip to content

Commit 02539da

Browse files
committed
Fix absurd upload corner case
1 parent 6cf5613 commit 02539da

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

cli/upload/upload.go

+13-20
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/arduino/arduino-cli/commands/upload"
2929
"github.com/arduino/arduino-cli/i18n"
3030
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
31-
"github.com/arduino/go-paths-helper"
3231
"github.com/spf13/cobra"
3332
)
3433

@@ -82,28 +81,22 @@ func run(command *cobra.Command, args []string) {
8281
if len(args) > 0 {
8382
path = args[0]
8483
}
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)
9985

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)
10591
}
10692
}
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+
107100
discoveryPort, err := port.GetPort(instance, sk)
108101
if err != nil {
109102
feedback.Errorf(tr("Error during Upload: %v"), err)

0 commit comments

Comments
 (0)