From b2a00ea155e9e5e6b60698cca6893377892b4191 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 12 Feb 2025 03:14:51 +0100 Subject: [PATCH] dev: fix JSONSchema publication --- scripts/website/copy_jsonschema/main.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/website/copy_jsonschema/main.go b/scripts/website/copy_jsonschema/main.go index e556f9574819..42e041303b42 100644 --- a/scripts/website/copy_jsonschema/main.go +++ b/scripts/website/copy_jsonschema/main.go @@ -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) @@ -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)