Check if dist dir exists (#54590)

This commit is contained in:
Dimitris Sotirakis 2022-09-01 17:43:04 +03:00 committed by GitHub
parent 59ba64f29b
commit 212f0609eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,16 +81,18 @@ func GenerateVersions(c *cli.Context) error {
}
const distDir = "dist"
if err := os.RemoveAll(distDir); err != nil {
return err
}
if err := os.Mkdir(distDir, 0750); err != nil {
return err
}
if _, err := os.Stat(distDir); os.IsNotExist(err) {
if err := os.RemoveAll(distDir); err != nil {
return err
}
if err := os.Mkdir(distDir, 0750); err != nil {
return err
}
// nolint:gosec
if err := os.WriteFile(filepath.Join(distDir, "version.json"), jsonMetadata, 0664); err != nil {
return err
// nolint:gosec
if err := os.WriteFile(filepath.Join(distDir, "version.json"), jsonMetadata, 0664); err != nil {
return err
}
}
return nil