Skip to content
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.

Commit

Permalink
fix: Format returns only the stdout of gno fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Dec 18, 2024
1 parent 72bd567 commit dcca0e3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/tools/format.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package tools

import (
"bytes"
"fmt"
"os/exec"
"strings"
)

func Format(file string) ([]byte, error) {
cmd := exec.Command("gno", "fmt", file)
bz, err := cmd.CombinedOutput()
var stdin, stderr bytes.Buffer
cmd.Stdout = &stdin
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
return bz, fmt.Errorf("running '%s': %w: %s", strings.Join(cmd.Args, " "), err, string(bz))
return nil, fmt.Errorf("running '%s': %w: %s", strings.Join(cmd.Args, " "), err, stderr.String())
}
return bz, nil
return stdin.Bytes(), nil
}

0 comments on commit dcca0e3

Please sign in to comment.