Improve LookPath

This commit is contained in:
Bjørn Erik Pedersen
2020-12-18 18:20:12 +01:00
parent ae2d1bd52d
commit 10ae7c3210
18 changed files with 129 additions and 42 deletions

View File

@@ -5,11 +5,12 @@ import (
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"github.com/gohugoio/hugo/common/hexec"
"github.com/gohugoio/hugo/common/hugio"
"github.com/spf13/afero"
@@ -203,7 +204,7 @@ func removeAll(expression, content string) string {
}
func rewrite(filename, rule string) {
cmf := exec.Command("gofmt", "-w", "-r", rule, filename)
cmf, _ := hexec.SafeCommand("gofmt", "-w", "-r", rule, filename)
out, err := cmf.CombinedOutput()
if err != nil {
log.Fatal("gofmt failed:", string(out))
@@ -211,7 +212,7 @@ func rewrite(filename, rule string) {
}
func goimports(dir string) {
cmf := exec.Command("goimports", "-w", dir)
cmf, _ := hexec.SafeCommand("goimports", "-w", dir)
out, err := cmf.CombinedOutput()
if err != nil {
log.Fatal("goimports failed:", string(out))
@@ -219,7 +220,7 @@ func goimports(dir string) {
}
func gofmt(dir string) {
cmf := exec.Command("gofmt", "-w", dir)
cmf, _ := hexec.SafeCommand("gofmt", "-w", dir)
out, err := cmf.CombinedOutput()
if err != nil {
log.Fatal("gofmt failed:", string(out))