mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
@@ -16,11 +16,11 @@ package postcss_test
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
jww "github.com/spf13/jwalterweatherman"
|
||||
|
||||
"github.com/bep/logg"
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/gohugoio/hugo/htesting"
|
||||
"github.com/gohugoio/hugo/hugofs"
|
||||
@@ -124,7 +124,7 @@ func TestTransformPostCSS(t *testing.T) {
|
||||
T: c,
|
||||
NeedsOsFS: true,
|
||||
NeedsNpmInstall: true,
|
||||
LogLevel: jww.LevelInfo,
|
||||
LogLevel: logg.LevelInfo,
|
||||
WorkingDir: tempDir,
|
||||
TxtarString: files,
|
||||
}).Build()
|
||||
@@ -148,6 +148,11 @@ func TestTransformPostCSSError(t *testing.T) {
|
||||
t.Skip("Skip long running test when running locally")
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
//TODO(bep) This has started to fail on Windows with Go 1.19 on GitHub Actions for some mysterious reason.
|
||||
t.Skip("Skip on Windows")
|
||||
}
|
||||
|
||||
c := qt.New(t)
|
||||
|
||||
s, err := hugolib.NewIntegrationTestBuilder(
|
||||
@@ -176,7 +181,7 @@ func TestTransformPostCSSImportError(t *testing.T) {
|
||||
T: c,
|
||||
NeedsOsFS: true,
|
||||
NeedsNpmInstall: true,
|
||||
LogLevel: jww.LevelInfo,
|
||||
LogLevel: logg.LevelInfo,
|
||||
TxtarString: strings.ReplaceAll(postCSSIntegrationTestFiles, `@import "components/all.css";`, `@import "components/doesnotexist.css";`),
|
||||
}).BuildE()
|
||||
|
||||
@@ -201,7 +206,7 @@ func TestTransformPostCSSImporSkipInlineImportsNotFound(t *testing.T) {
|
||||
T: c,
|
||||
NeedsOsFS: true,
|
||||
NeedsNpmInstall: true,
|
||||
LogLevel: jww.LevelInfo,
|
||||
LogLevel: logg.LevelInfo,
|
||||
TxtarString: files,
|
||||
}).Build()
|
||||
|
||||
@@ -233,7 +238,7 @@ func TestTransformPostCSSResourceCacheWithPathInBaseURL(t *testing.T) {
|
||||
T: c,
|
||||
NeedsOsFS: true,
|
||||
NeedsNpmInstall: true,
|
||||
LogLevel: jww.LevelInfo,
|
||||
LogLevel: logg.LevelInfo,
|
||||
TxtarString: files,
|
||||
WorkingDir: tempDir,
|
||||
}).Build()
|
||||
|
@@ -27,13 +27,12 @@ import (
|
||||
|
||||
"github.com/gohugoio/hugo/common/collections"
|
||||
"github.com/gohugoio/hugo/common/hexec"
|
||||
"github.com/gohugoio/hugo/common/loggers"
|
||||
"github.com/gohugoio/hugo/common/text"
|
||||
"github.com/gohugoio/hugo/hugofs"
|
||||
|
||||
"github.com/gohugoio/hugo/common/hugo"
|
||||
|
||||
"github.com/gohugoio/hugo/common/loggers"
|
||||
|
||||
"github.com/gohugoio/hugo/resources/internal"
|
||||
"github.com/spf13/afero"
|
||||
"github.com/spf13/cast"
|
||||
@@ -151,10 +150,12 @@ func (t *postcssTransformation) Key() internal.ResourceTransformationKey {
|
||||
func (t *postcssTransformation) Transform(ctx *resources.ResourceTransformationCtx) error {
|
||||
const binaryName = "postcss"
|
||||
|
||||
infol := t.rs.Logger.InfoCommand(binaryName)
|
||||
infoW := loggers.LevelLoggerToWriter(infol)
|
||||
|
||||
ex := t.rs.ExecHelper
|
||||
|
||||
var configFile string
|
||||
logger := t.rs.Logger
|
||||
|
||||
var options Options
|
||||
if t.optionsm != nil {
|
||||
@@ -185,7 +186,7 @@ func (t *postcssTransformation) Transform(ctx *resources.ResourceTransformationC
|
||||
var cmdArgs []any
|
||||
|
||||
if configFile != "" {
|
||||
logger.Infoln("postcss: use config file", configFile)
|
||||
infol.Logf("use config file %q", configFile)
|
||||
cmdArgs = []any{"--config", configFile}
|
||||
}
|
||||
|
||||
@@ -194,7 +195,6 @@ func (t *postcssTransformation) Transform(ctx *resources.ResourceTransformationC
|
||||
}
|
||||
|
||||
var errBuf bytes.Buffer
|
||||
infoW := loggers.LoggerToWriterWithPrefix(logger.Info(), "postcss")
|
||||
|
||||
stderr := io.MultiWriter(infoW, &errBuf)
|
||||
cmdArgs = append(cmdArgs, hexec.WithStderr(stderr))
|
||||
@@ -401,7 +401,6 @@ func (imp *importResolver) shouldImport(s string) bool {
|
||||
}
|
||||
|
||||
func (imp *importResolver) toFileError(output string) error {
|
||||
output = strings.TrimSpace(loggers.RemoveANSIColours(output))
|
||||
inErr := errors.New(output)
|
||||
|
||||
match := cssSyntaxErrorRe.FindStringSubmatch(output)
|
||||
|
@@ -18,9 +18,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gohugoio/hugo/common/loggers"
|
||||
"github.com/gohugoio/hugo/htesting/hqt"
|
||||
|
||||
"github.com/gohugoio/hugo/common/loggers"
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
@@ -95,7 +95,7 @@ LOCAL_STYLE
|
||||
mainStyles,
|
||||
"styles.css",
|
||||
Options{},
|
||||
fs, loggers.NewErrorLogger(),
|
||||
fs, loggers.NewDefault(),
|
||||
)
|
||||
|
||||
r, err := imp.resolve()
|
||||
@@ -144,7 +144,7 @@ LOCAL_STYLE
|
||||
@import "e.css";
|
||||
@import "missing.css";`
|
||||
|
||||
logger := loggers.NewErrorLogger()
|
||||
logger := loggers.NewDefault()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
b.StopTimer()
|
||||
|
Reference in New Issue
Block a user