Skip to content

Commit

Permalink
fix: improve script file handling and testing robustness
Browse files Browse the repository at this point in the history
- Add a check to verify if the script file exists before reading it

Signed-off-by: appleboy <[email protected]>
  • Loading branch information
appleboy committed Nov 17, 2024
1 parent d56db7a commit 2c52afb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ func run(c *cli.Context) error {
}

if f := c.String("script.file"); f != "" {
// check file exists
if _, err := os.Stat(f); err != nil {
return err
}
s, err := os.ReadFile(f)
if err != nil {
return err
Expand Down

0 comments on commit 2c52afb

Please sign in to comment.