Skip to content

Commit 9ad2f91

Browse files
committed
Inline function call
1 parent cf4505e commit 9ad2f91

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

commands/sketch/warn_deprecated.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,23 @@ package sketch
1818
import (
1919
"fmt"
2020

21-
"github.com/arduino/arduino-cli/internal/arduino/sketch"
2221
paths "github.com/arduino/go-paths-helper"
2322
)
2423

2524
// WarnDeprecatedFiles warns the user that a type of sketch files are deprecated
2625
func WarnDeprecatedFiles(sketchPath *paths.Path) string {
26+
if sketchPath.IsNotDir() {
27+
sketchPath = sketchPath.Parent()
28+
}
29+
30+
files, err := sketchPath.ReadDirRecursive()
31+
if err != nil {
32+
return ""
33+
}
34+
files.FilterSuffix(".pde")
35+
2736
// .pde files are still supported but deprecated, this warning urges the user to rename them
28-
if files := sketch.CheckForPdeFiles(sketchPath); len(files) > 0 {
37+
if len(files) > 0 {
2938
msg := tr("Sketches with .pde extension are deprecated, please rename the following files to .ino:")
3039
for _, f := range files {
3140
msg += fmt.Sprintf("\n - %s", f)

internal/arduino/sketch/sketch.go

-17
Original file line numberDiff line numberDiff line change
@@ -280,23 +280,6 @@ func (e *InvalidSketchFolderNameError) Error() string {
280280
return tr("no valid sketch found in %[1]s: missing %[2]s", e.SketchFolder, e.SketchFile)
281281
}
282282

283-
// CheckForPdeFiles returns all files ending with .pde extension
284-
// in sketch, this is mainly used to warn the user that these files
285-
// must be changed to .ino extension.
286-
// When .pde files won't be supported anymore this function must be removed.
287-
func CheckForPdeFiles(sketch *paths.Path) []*paths.Path {
288-
if sketch.IsNotDir() {
289-
sketch = sketch.Parent()
290-
}
291-
292-
files, err := sketch.ReadDirRecursive()
293-
if err != nil {
294-
return []*paths.Path{}
295-
}
296-
files.FilterSuffix(".pde")
297-
return files
298-
}
299-
300283
// DefaultBuildPath generates the default build directory for a given sketch.
301284
// The build path is in a temporary directory and is unique for each sketch.
302285
func (s *Sketch) DefaultBuildPath() *paths.Path {

0 commit comments

Comments
 (0)