Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading