fix: improve script file handling and testing robustness

- Add a check to verify if the script file exists before reading it

Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
appleboy 2024-11-17 14:32:06 +08:00
parent d56db7a5b3
commit 2c52afb7fd
No known key found for this signature in database

View File

@ -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