Skip to content

Commit 750e914

Browse files
committed
fix a regression introduced in #be5022e. --input flags were ignored (#1558)
* fix a regression introduced in be5022e. `--input` flags were ignored partially revert "refactor sketch path calculation" in `upload.go` * fix test after f85513c * use `WarnDeprecatedFiles` to remove some code duplication
1 parent eff632c commit 750e914

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

cli/upload/upload.go

+17-3
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,23 @@ 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+
if importDir == "" && importFile == "" {
83+
arguments.WarnDeprecatedFiles(sketchPath)
84+
}
85+
86+
sk, err := sketch.New(sketchPath)
87+
if err != nil && importDir == "" && importFile == "" {
88+
feedback.Errorf(tr("Error during Upload: %v"), err)
89+
os.Exit(errorcodes.ErrGeneric)
90+
}
91+
92+
discoveryPort, err := port.GetPort(instance, sk)
93+
if err != nil {
94+
feedback.Errorf(tr("Error during Upload: %v"), err)
95+
os.Exit(errorcodes.ErrGeneric)
96+
}
8397

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

test/test_upload.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_upload_after_attach(run_command, data_dir, detected_boards):
111111
# Create a sketch
112112
sketch_path = os.path.join(data_dir, "foo")
113113
assert run_command(["sketch", "new", sketch_path])
114-
assert run_command(["board", "attach", f"serial://{board.address}", sketch_path])
114+
assert run_command(["board", "attach", "-p", board.address, sketch_path])
115115
# Build sketch
116116
assert run_command(["compile", sketch_path])
117117
# Upload

0 commit comments

Comments
 (0)