Skip to content

fix a regression introduced in #be5022e. --input flags were ignored #1558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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