Skip to content

Commit bdc0916

Browse files
authored
Merge pull request #29 from per1234/arduino-lint-path-configuration
Add Arduino Lint installation path as a configuration field
2 parents 2344567 + a94d088 commit bdc0916

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

config.json.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"LibrariesIndex": "/tmp/libraries/library_index.json",
55
"LibrariesDB": "/tmp/libraries_db.json",
66
"GitClonesFolder": "/tmp/gitclones",
7+
"ArduinoLintPath": "/usr/bin/arduino-lint",
78
"CronTabEntry": "0 0 0 * * *"
8-
}
9+
}

libraries/lint.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ func official(metadata *Repo) bool {
4949
}
5050

5151
// RunArduinoLint runs Arduino Lint on the library and returns the report in the event of error or warnings.
52-
func RunArduinoLint(folder string, metadata *Repo) ([]byte, error) {
52+
func RunArduinoLint(arduinoLintPath string, folder string, metadata *Repo) ([]byte, error) {
53+
if arduinoLintPath == "" {
54+
// Assume Arduino Lint is installed under PATH.
55+
arduinoLintPath = "arduino-lint"
56+
}
57+
5358
JSONReportFolder, err := ioutil.TempDir("", "arduino-lint-report-")
5459
if err != nil {
5560
panic(err)
@@ -59,7 +64,7 @@ func RunArduinoLint(folder string, metadata *Repo) ([]byte, error) {
5964

6065
// See: https://arduino.github.io/arduino-lint/latest/commands/arduino-lint/
6166
cmd := exec.Command(
62-
"arduino-lint",
67+
arduinoLintPath,
6368
"--compliance=permissive",
6469
"--format=text",
6570
"--project-type=library",

libraries/lint_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestRunArduinoLint(t *testing.T) {
101101
} else {
102102
metadata.Types = []string{"Contributed"}
103103
}
104-
report, err := RunArduinoLint(filepath.Join(testDataPath, "libraries", testTable.folder), &metadata)
104+
report, err := RunArduinoLint("", filepath.Join(testDataPath, "libraries", testTable.folder), &metadata)
105105
assert.Regexp(t, regexp.MustCompile(testTable.reportRegexp), string(report), testTable.testName)
106106
testTable.errorAssertion(t, err, testTable.testName)
107107
}

sync_libraries.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type Config struct {
5050
LibrariesIndex string
5151
GitClonesFolder string
5252
DoNotRunClamav bool
53+
ArduinoLintPath string
5354
}
5455

5556
func logError(err error) bool {
@@ -304,7 +305,7 @@ func syncLibraryTaggedRelease(logger *log.Logger, repo *libraries.Repository, ta
304305
}
305306
}
306307

307-
report, err := libraries.RunArduinoLint(repo.FolderPath, repoMeta)
308+
report, err := libraries.RunArduinoLint(config.ArduinoLintPath, repo.FolderPath, repoMeta)
308309
reportTemplate := `<a href="https://arduino.github.io/arduino-lint/latest/">Arduino Lint</a> %s:
309310
<details><summary>Click to expand Arduino Lint report</summary>
310311
<hr>

0 commit comments

Comments
 (0)