Skip to content
Prev Previous commit
Next Next commit
Inline function call
  • Loading branch information
cmaglie committed Jan 5, 2024
commit 9ad2f917c817bf96364cfe40610114c1e0b218cf
13 changes: 11 additions & 2 deletions commands/sketch/warn_deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@ package sketch
import (
"fmt"

"github.com/arduino/arduino-cli/internal/arduino/sketch"
paths "github.com/arduino/go-paths-helper"
)

// WarnDeprecatedFiles warns the user that a type of sketch files are deprecated
func WarnDeprecatedFiles(sketchPath *paths.Path) string {
if sketchPath.IsNotDir() {
sketchPath = sketchPath.Parent()
}

files, err := sketchPath.ReadDirRecursive()
if err != nil {
return ""
}
files.FilterSuffix(".pde")

// .pde files are still supported but deprecated, this warning urges the user to rename them
if files := sketch.CheckForPdeFiles(sketchPath); len(files) > 0 {
if len(files) > 0 {
msg := tr("Sketches with .pde extension are deprecated, please rename the following files to .ino:")
for _, f := range files {
msg += fmt.Sprintf("\n - %s", f)
Expand Down
17 changes: 0 additions & 17 deletions internal/arduino/sketch/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,6 @@ func (e *InvalidSketchFolderNameError) Error() string {
return tr("no valid sketch found in %[1]s: missing %[2]s", e.SketchFolder, e.SketchFile)
}

// CheckForPdeFiles returns all files ending with .pde extension
// in sketch, this is mainly used to warn the user that these files
// must be changed to .ino extension.
// When .pde files won't be supported anymore this function must be removed.
func CheckForPdeFiles(sketch *paths.Path) []*paths.Path {
if sketch.IsNotDir() {
sketch = sketch.Parent()
}

files, err := sketch.ReadDirRecursive()
if err != nil {
return []*paths.Path{}
}
files.FilterSuffix(".pde")
return files
}

// DefaultBuildPath generates the default build directory for a given sketch.
// The build path is in a temporary directory and is unique for each sketch.
func (s *Sketch) DefaultBuildPath() *paths.Path {
Expand Down