Skip to content

Commit 90bf1e3

Browse files
committed
Fix sketch loading with different kind of input paths
1 parent 8b76e2e commit 90bf1e3

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

arduino/sketches/sketches.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ type BoardMetadata struct {
4343

4444
// NewSketchFromPath loads a sketch from the specified path
4545
func NewSketchFromPath(path *paths.Path) (*Sketch, error) {
46+
if !path.IsDir() {
47+
path = path.Parent()
48+
}
4649
sketch := &Sketch{
4750
FullPath: path,
4851
Name: path.Base(),

commands/compile/compile.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,7 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W
211211
var exportPath *paths.Path
212212
var exportFile string
213213
if req.GetExportFile() == "" {
214-
if sketch.FullPath.IsDir() {
215-
exportPath = sketch.FullPath
216-
} else {
217-
exportPath = sketch.FullPath.Parent()
218-
}
214+
exportPath = sketch.FullPath
219215
exportFile = sketch.Name + "." + fqbnSuffix // "sketch.arduino.avr.uno"
220216
} else {
221217
exportPath = paths.New(req.GetExportFile()).Parent()

0 commit comments

Comments
 (0)