Skip to content

Commit

Permalink
Fix broken file reader
Browse files Browse the repository at this point in the history
  • Loading branch information
thegridman committed Sep 23, 2024
1 parent bdae89c commit d1ef449
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,24 +626,22 @@ func createJavaCommand(javaCmd string, details *RunDetails) (*exec.Cmd, error) {
}

func readFirstLineFromFile(path string) (string, error) {
st, err := os.Stat(maybeStripFileScheme(path))
if err != nil {
return "", err
}
if st.IsDir() {
return "", fmt.Errorf("%s is a directory", path)
}
file, err := os.Open(path)
file, err := os.Open(maybeStripFileScheme(path))
if err != nil {
return "", err
}
defer closeFile(file, log)
rd := bufio.NewReader(file)
data, _, err := rd.ReadLine()
if err != nil {
return "", err

scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
var text []string
for scanner.Scan() {
text = append(text, scanner.Text())
}
if len(text) == 0 {
return "", nil
}
return string(data), nil
return text[0], nil
}

func createSpringBootCommand(javaCmd string, details *RunDetails) (*exec.Cmd, error) {
Expand Down

0 comments on commit d1ef449

Please sign in to comment.