Skip to content

Commit

Permalink
fix: Remove quoting for script path
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Nov 17, 2022
1 parent 7d7cc2e commit 60543d6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/lefthook/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,16 @@ func (r *Runner) runScripts(dir string) {
continue
}

unquotedScriptPath := filepath.Join(dir, file.Name())
path := filepath.Join(dir, file.Name())

if r.hook.Parallel {
wg.Add(1)
go func(script *config.Script, path string, file os.FileInfo) {
defer wg.Done()
r.runScript(script, path, file)
}(script, unquotedScriptPath, file)
}(script, path, file)
} else {
r.runScript(script, unquotedScriptPath, file)
r.runScript(script, path, file)
}
}

Expand All @@ -185,13 +185,13 @@ func (r *Runner) runScripts(dir string) {
continue
}

unquotedScriptPath := filepath.Join(dir, file.Name())
path := filepath.Join(dir, file.Name())

r.runScript(script, unquotedScriptPath, file)
r.runScript(script, path, file)
}
}

func (r *Runner) runScript(script *config.Script, unquotedPath string, file os.FileInfo) {
func (r *Runner) runScript(script *config.Script, path string, file os.FileInfo) {
if script.DoSkip(r.repo.State()) {
logSkip(file.Name(), "(SKIP BY SETTINGS)")
return
Expand All @@ -210,7 +210,7 @@ func (r *Runner) runScript(script *config.Script, unquotedPath string, file os.F

// Make sure file is executable
if (file.Mode() & executableMask) == 0 {
if err := r.fs.Chmod(unquotedPath, executableFileMode); err != nil {
if err := r.fs.Chmod(path, executableFileMode); err != nil {
log.Errorf("Couldn't change file mode to make file executable: %s", err)
r.fail(file.Name(), "")
return
Expand All @@ -222,7 +222,7 @@ func (r *Runner) runScript(script *config.Script, unquotedPath string, file os.F
args = strings.Split(script.Runner, " ")
}

args = append(args, fmt.Sprintf("%#v", unquotedPath))
args = append(args, path)
args = append(args, r.args[:]...)

if script.Interactive {
Expand Down

0 comments on commit 60543d6

Please sign in to comment.