Skip to content

Commit a93bb53

Browse files
committed
use cwd when given path is empty on LintRepository and GenerateDefaultConfig
1 parent 07cafa0 commit a93bb53

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ func (cmd *Command) runLinter(args []string, opts *LinterOptions, initConfig boo
9494
}
9595

9696
if initConfig {
97-
return nil, l.GenerateDefaultConfig(".")
97+
return nil, l.GenerateDefaultConfig("")
9898
}
9999

100100
if len(args) == 0 {
101-
return l.LintRepository(".")
101+
return l.LintRepository("")
102102
}
103103

104104
if len(args) == 1 && args[0] == "-" {

linter.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,13 @@ func (l *Linter) debugWriter() io.Writer {
222222
}
223223

224224
// GenerateDefaultConfig generates default config file at ".github/actionlint.yaml" in the project
225-
// which the given directory path belongs to.
225+
// which the given directory path belongs to. When the directory path is empty, the current directory
226+
// will be used instead.
226227
func (l *Linter) GenerateDefaultConfig(dir string) error {
228+
if dir == "" {
229+
dir = l.cwd
230+
}
231+
227232
l.log("Generating default actionlint.yaml in repository:", dir)
228233

229234
proj, err := l.projects.At(dir)
@@ -251,10 +256,15 @@ func (l *Linter) GenerateDefaultConfig(dir string) error {
251256
return nil
252257
}
253258

254-
// LintRepository lints YAML workflow files and outputs the errors to given writer. It finds the nearest
255-
// `.github/workflows` directory based on `dir` and applies lint rules to all YAML workflow files
256-
// under the directory.
259+
// LintRepository lints YAML workflow files and outputs the errors to given writer. It finds the
260+
// nearest `.github/workflows` directory based on `dir` and applies lint rules to all YAML workflow
261+
// files under the directory. When the directory path is empty, the current working directory will
262+
// be used instead.
257263
func (l *Linter) LintRepository(dir string) ([]*Error, error) {
264+
if dir == "" {
265+
dir = l.cwd
266+
}
267+
258268
l.log("Linting all workflow files in repository:", dir)
259269

260270
p, err := l.projects.At(dir)

0 commit comments

Comments
 (0)