(path string)
| 157 | } |
| 158 | |
| 159 | func dirOption(path string) interp.RunnerOption { |
| 160 | return func(r *interp.Runner) error { |
| 161 | err := interp.Dir(path)(r) |
| 162 | if err == nil { |
| 163 | return nil |
| 164 | } |
| 165 | |
| 166 | // If the specified directory doesn't exist, it will be created later. |
| 167 | // Therefore, even if `interp.Dir` method returns an error, the |
| 168 | // directory path should be set only when the directory cannot be found. |
| 169 | if absPath, _ := filepath.Abs(path); absPath != "" { |
| 170 | if _, err := os.Stat(absPath); os.IsNotExist(err) { |
| 171 | r.Dir = absPath |
| 172 | return nil |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | return err |
| 177 | } |
| 178 | } |
no test coverage detected
searching dependent graphs…