Skip to content

Commit fb49bcf

Browse files
committed
Move SchemasPath() to the configuration package
1 parent e47fcda commit fb49bcf

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Diff for: check/checkdata/schema/schema.go

-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,13 @@ package schema
33

44
import (
55
"net/url"
6-
"os"
76
"path/filepath"
87
"regexp"
98

109
"github.com/arduino/go-paths-helper"
1110
"github.com/xeipuuv/gojsonschema"
1211
)
1312

14-
// SchemasPath returns the path to the folder containing the JSON schemas.
15-
func SchemasPath() *paths.Path {
16-
workingPath, _ := os.Getwd()
17-
return paths.New(workingPath)
18-
}
19-
2013
// Compile compiles the schema files specified by the filename arguments and returns the compiled schema.
2114
func Compile(schemaFilename string, referencedSchemaFilenames []string, schemasPath *paths.Path) *gojsonschema.Schema {
2215
schemaLoader := gojsonschema.NewSchemaLoader()

Diff for: configuration/configuration.go

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
package configuration
33

44
import (
5+
"os"
6+
57
"github.com/arduino/arduino-check/configuration/checkmode"
68
"github.com/arduino/arduino-check/project/projecttype"
79
"github.com/arduino/arduino-check/result/outputformat"
@@ -79,3 +81,9 @@ var targetPath *paths.Path
7981
func TargetPath() *paths.Path {
8082
return targetPath
8183
}
84+
85+
// SchemasPath returns the path to the folder containing the JSON schemas.
86+
func SchemasPath() *paths.Path {
87+
workingPath, _ := os.Getwd()
88+
return paths.New(workingPath)
89+
}

Diff for: project/library/libraryproperties/libraryproperties.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package libraryproperties
33

44
import (
55
"github.com/arduino/arduino-check/check/checkdata/schema"
6+
"github.com/arduino/arduino-check/configuration"
67
"github.com/arduino/go-paths-helper"
78
"github.com/arduino/go-properties-orderedmap"
89
"github.com/xeipuuv/gojsonschema"
@@ -20,7 +21,7 @@ func Properties(libraryPath *paths.Path) (*properties.Map, error) {
2021
// Validate validates library.properties data against the JSON schema.
2122
func Validate(libraryProperties *properties.Map) *gojsonschema.Result {
2223
referencedSchemaFilenames := []string{}
23-
schemaObject := schema.Compile("arduino-library-properties-schema.json", referencedSchemaFilenames, schema.SchemasPath())
24+
schemaObject := schema.Compile("arduino-library-properties-schema.json", referencedSchemaFilenames, configuration.SchemasPath())
2425

2526
return schema.Validate(libraryProperties, schemaObject)
2627
}

0 commit comments

Comments
 (0)