Skip to content

Commit a248c3b

Browse files
committed
fix a regression introduced in be5022e. --input flags were ignored
partially revert "refactor sketch path calculation" in `upload.go`
1 parent eff632c commit a248c3b

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

cli/upload/upload.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"context"
2020
"os"
2121

22+
"github.com/arduino/arduino-cli/arduino/sketch"
2223
"github.com/arduino/arduino-cli/cli/arguments"
2324
"github.com/arduino/arduino-cli/cli/errorcodes"
2425
"github.com/arduino/arduino-cli/cli/feedback"
@@ -76,10 +77,27 @@ func runUploadCommand(command *cobra.Command, args []string) {
7677
if len(args) > 0 {
7778
path = args[0]
7879
}
79-
8080
sketchPath := arguments.InitSketchPath(path)
81-
sk := arguments.NewSketch(sketchPath)
82-
discoveryPort := port.GetDiscoveryPort(instance, sk)
81+
82+
// .pde files are still supported but deprecated, this warning urges the user to rename them
83+
if files := sketch.CheckForPdeFiles(sketchPath); len(files) > 0 && importDir == "" && importFile == "" {
84+
feedback.Error(tr("Sketches with .pde extension are deprecated, please rename the following files to .ino:"))
85+
for _, f := range files {
86+
feedback.Error(f)
87+
}
88+
}
89+
90+
sk, err := sketch.New(sketchPath)
91+
if err != nil && importDir == "" && importFile == "" {
92+
feedback.Errorf(tr("Error during Upload: %v"), err)
93+
os.Exit(errorcodes.ErrGeneric)
94+
}
95+
96+
discoveryPort, err := port.GetPort(instance, sk)
97+
if err != nil {
98+
feedback.Errorf(tr("Error during Upload: %v"), err)
99+
os.Exit(errorcodes.ErrGeneric)
100+
}
83101

84102
if fqbn.String() == "" && sk != nil && sk.Metadata != nil {
85103
// If the user didn't specify an FQBN and a sketch.json file is present

0 commit comments

Comments
 (0)