()
| 55 | func (s GenericScript) Exists() bool { return s.fs.FileExists(s.path) } |
| 56 | |
| 57 | func (s GenericScript) Run() error { |
| 58 | err := s.ensureContainingDir(s.stdoutLogPath) |
| 59 | if err != nil { |
| 60 | return err |
| 61 | } |
| 62 | |
| 63 | err = s.ensureContainingDir(s.stderrLogPath) |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } |
| 67 | |
| 68 | stdoutFile, err := s.fs.OpenFile(s.stdoutLogPath, fileOpenFlag, fileOpenPerm) |
| 69 | if err != nil { |
| 70 | return err |
| 71 | } |
| 72 | defer func() { |
| 73 | _ = stdoutFile.Close() //nolint:errcheck |
| 74 | }() |
| 75 | |
| 76 | stderrFile, err := s.fs.OpenFile(s.stderrLogPath, fileOpenFlag, fileOpenPerm) |
| 77 | if err != nil { |
| 78 | return err |
| 79 | } |
| 80 | defer func() { |
| 81 | _ = stderrFile.Close() //nolint:errcheck |
| 82 | }() |
| 83 | |
| 84 | command := cmd.BuildCommand(s.path) |
| 85 | command.Stdout = stdoutFile |
| 86 | command.Stderr = stderrFile |
| 87 | command.SpawnWithLowerPriority = true |
| 88 | |
| 89 | for key, val := range s.env { |
| 90 | command.Env[key] = val |
| 91 | } |
| 92 | |
| 93 | _, _, _, err = s.runner.RunComplexCommand(command) //nolint:errcheck |
| 94 | |
| 95 | return err |
| 96 | } |
| 97 | |
| 98 | func (s GenericScript) ensureContainingDir(fullLogFilename string) error { |
| 99 | dir, _ := filepath.Split(fullLogFilename) |
nothing calls this directly
no test coverage detected