@@ -24,15 +24,9 @@ func absPath(path string) string {
24
24
func findProject (path string ) (* Project , error ) {
25
25
d := absPath (path )
26
26
for {
27
- w := filepath .Join (d , ".github" , "workflows" )
28
- if s , err := os .Stat (w ); err == nil && s .IsDir () {
29
- g := filepath .Join (d , ".git" )
30
- if _ , err := os .Stat (g ); err == nil { // Note: .git may be a file
31
- c , err := loadRepoConfig (d )
32
- if err != nil {
33
- return nil , err
34
- }
35
- return & Project {root : d , config : c }, nil
27
+ if s , err := os .Stat (filepath .Join (d , ".github" , "workflows" )); err == nil && s .IsDir () {
28
+ if _ , err := os .Stat (filepath .Join (d , ".git" )); err == nil { // Note: .git may be a file
29
+ return NewProject (d )
36
30
}
37
31
}
38
32
@@ -44,6 +38,16 @@ func findProject(path string) (*Project, error) {
44
38
}
45
39
}
46
40
41
+ // NewProject creates a new instance with a file path to the root directory of the repository.
42
+ // This function returns an error when failing to parse an actionlint config file in the repository.
43
+ func NewProject (root string ) (* Project , error ) {
44
+ c , err := loadRepoConfig (root )
45
+ if err != nil {
46
+ return nil , err
47
+ }
48
+ return & Project {root , c }, nil
49
+ }
50
+
47
51
// RootDir returns a root directory path of the GitHub project repository.
48
52
func (p * Project ) RootDir () string {
49
53
return p .root
0 commit comments