From d8efe085ca8a8bd342bd45cda1d7c8a5f51cc791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 6 Dec 2022 12:09:41 +0100 Subject: [PATCH] Add dart-sass-embedded version info to hugo env -v MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` ~ ❯❯❯ hugo env -v | grep dart github.com/bep/godartsass="v0.16.0" github.com/sass/dart-sass-embedded/compiler="1.56.1" github.com/sass/dart-sass-embedded/implementation="1.56.1" github.com/sass/dart-sass-embedded/protocol="1.1.0" ``` --- common/hugo/hugo.go | 22 ++++++++++++++++++++++ go.sum | 2 -- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/common/hugo/hugo.go b/common/hugo/hugo.go index 0a79576f3..f463e261d 100644 --- a/common/hugo/hugo.go +++ b/common/hugo/hugo.go @@ -24,6 +24,8 @@ import ( "sync" "time" + "github.com/bep/godartsass" + "github.com/gohugoio/hugo/common/hexec" "github.com/gohugoio/hugo/hugofs/files" "github.com/spf13/afero" @@ -202,6 +204,16 @@ func GetDependencyList() []string { ) } + if dartSass := dartSassVersion(); dartSass.ProtocolVersion != "" { + const dartSassPath = "github.com/sass/dart-sass-embedded" + deps = append(deps, + formatDep(dartSassPath+"/protocol", dartSass.ProtocolVersion), + formatDep(dartSassPath+"/compiler", dartSass.CompilerVersion), + formatDep(dartSassPath+"/implementation", dartSass.ImplementationVersion), + ) + + } + bi := getBuildInfo() if bi == nil { return deps @@ -249,3 +261,13 @@ type Dependency struct { // Replaced by this dependency. Replace *Dependency } + +func dartSassVersion() godartsass.DartSassVersion { + // This is also duplicated in the dartsass package. + const dartSassEmbeddedBinaryName = "dart-sass-embedded" + if !hexec.InPath(dartSassEmbeddedBinaryName) { + return godartsass.DartSassVersion{} + } + v, _ := godartsass.Version(dartSassEmbeddedBinaryName) + return v +} diff --git a/go.sum b/go.sum index 7dcf3e74e..6f5cd657e 100644 --- a/go.sum +++ b/go.sum @@ -173,8 +173,6 @@ github.com/bep/gitmap v1.1.2 h1:zk04w1qc1COTZPPYWDQHvns3y1afOsdRfraFQ3qI840= github.com/bep/gitmap v1.1.2/go.mod h1:g9VRETxFUXNWzMiuxOwcudo6DfZkW9jOsOW0Ft4kYaY= github.com/bep/goat v0.5.0 h1:S8jLXHCVy/EHIoCY+btKkmcxcXFd34a0Q63/0D4TKeA= github.com/bep/goat v0.5.0/go.mod h1:Md9x7gRxiWKs85yHlVTvHQw9rg86Bm+Y4SuYE8CTH7c= -github.com/bep/godartsass v0.15.0 h1:O7SOIQGmyu7YvbsEqZuqIBYepUH7j3PPs7JV0nUjuTk= -github.com/bep/godartsass v0.15.0/go.mod h1:6LvK9RftsXMxGfsA0LDV12AGc4Jylnu6NgHL+Q5/pE8= github.com/bep/godartsass v0.16.0 h1:nTpenrZBQjVSjLkCw3AgnYmBB2czauTJa4BLLv448qg= github.com/bep/godartsass v0.16.0/go.mod h1:6LvK9RftsXMxGfsA0LDV12AGc4Jylnu6NgHL+Q5/pE8= github.com/bep/golibsass v1.1.0 h1:pjtXr00IJZZaOdfryNa9wARTB3Q0BmxC3/V1KNcgyTw=