Skip to content

Commit

Permalink
dev: fix JSONSchema publication (#5395)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Feb 12, 2025
1 parent 2b74eba commit f5396bd
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions scripts/website/copy_jsonschema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ func copyLatestSchema(dstDir string) error {
fmt.Sprintf("golangci.v%d.%d.jsonschema.json", version.Segments()[0], version.Segments()[1]),
}

for _, dst := range files {
err = copyFile(filepath.Join(dstDir, dst), src)
if err != nil {
return fmt.Errorf("copy file %s to %s: %w", src, dst, err)
}
}

return nil
}

func copyFile(dst, src string) error {
source, err := os.Open(src)
if err != nil {
return fmt.Errorf("open file %s: %w", src, err)
Expand All @@ -70,17 +81,6 @@ func copyLatestSchema(dstDir string) error {
return fmt.Errorf("file %s not found: %w", src, err)
}

for _, dst := range files {
err = copyFile(filepath.Join(dstDir, dst), source, info)
if err != nil {
return fmt.Errorf("copy file %s to %s: %w", src, dst, err)
}
}

return nil
}

func copyFile(dst string, source io.Reader, info os.FileInfo) error {
destination, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, info.Mode())
if err != nil {
return fmt.Errorf("create file %s: %w", dst, err)
Expand Down

0 comments on commit f5396bd

Please sign in to comment.