Skip to content

Commit

Permalink
fix a regression introduced in #be5022e. --input flags were ignored (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
umbynos committed Nov 22, 2021
1 parent eff632c commit 89dbd25
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions cli/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"os"

"github.com/arduino/arduino-cli/arduino/sketch"
"github.com/arduino/arduino-cli/cli/arguments"
"github.com/arduino/arduino-cli/cli/errorcodes"
"github.com/arduino/arduino-cli/cli/feedback"
Expand Down Expand Up @@ -76,10 +77,23 @@ func runUploadCommand(command *cobra.Command, args []string) {
if len(args) > 0 {
path = args[0]
}

sketchPath := arguments.InitSketchPath(path)
sk := arguments.NewSketch(sketchPath)
discoveryPort := port.GetDiscoveryPort(instance, sk)

if importDir == "" && importFile == "" {
arguments.WarnDeprecatedFiles(sketchPath)
}

sk, err := sketch.New(sketchPath)
if err != nil && importDir == "" && importFile == "" {
feedback.Errorf(tr("Error during Upload: %v"), err)
os.Exit(errorcodes.ErrGeneric)
}

discoveryPort, err := port.GetPort(instance, sk)
if err != nil {
feedback.Errorf(tr("Error during Upload: %v"), err)
os.Exit(errorcodes.ErrGeneric)
}

if fqbn.String() == "" && sk != nil && sk.Metadata != nil {
// If the user didn't specify an FQBN and a sketch.json file is present
Expand Down
2 changes: 1 addition & 1 deletion test/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_upload_after_attach(run_command, data_dir, detected_boards):
# Create a sketch
sketch_path = os.path.join(data_dir, "foo")
assert run_command(["sketch", "new", sketch_path])
assert run_command(["board", "attach", f"serial://{board.address}", sketch_path])
assert run_command(["board", "attach", "-p", board.address, sketch_path])
# Build sketch
assert run_command(["compile", sketch_path])
# Upload
Expand Down

0 comments on commit 89dbd25

Please sign in to comment.