Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-12-23 11:26:23 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-12-30 19:32:25 +0300
commitcea157402365f34a69882110a4208999728007a6 (patch)
treebc29f699e7c901c219cffc5f50fba99dca53d5bd /deps
parentf9f779786edcefc4449a14cfc04dd93379f71373 (diff)
Add Dart Sass support
But note that the Dart Sass Embedded Protocol is still in beta (beta 5), a main release scheduled for Q1 2021. Fixes #7380 Fixes #8102
Diffstat (limited to 'deps')
-rw-r--r--deps/deps.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/deps/deps.go b/deps/deps.go
index c2919c9c5..36620c96b 100644
--- a/deps/deps.go
+++ b/deps/deps.go
@@ -94,6 +94,9 @@ type Deps struct {
// BuildStartListeners will be notified before a build starts.
BuildStartListeners *Listeners
+ // Resources that gets closed when the build is done or the server shuts down.
+ BuildClosers *Closers
+
// Atomic values set during a build.
// This is common/global for all sites.
BuildState *BuildState
@@ -284,6 +287,7 @@ func New(cfg DepsCfg) (*Deps, error) {
Site: cfg.Site,
FileCaches: fileCaches,
BuildStartListeners: &Listeners{},
+ BuildClosers: &Closers{},
BuildState: buildState,
Running: cfg.Running,
Timeout: time.Duration(timeoutms) * time.Millisecond,
@@ -297,6 +301,10 @@ func New(cfg DepsCfg) (*Deps, error) {
return d, nil
}
+func (d *Deps) Close() error {
+ return d.BuildClosers.Close()
+}
+
// ForLanguage creates a copy of the Deps with the language dependent
// parts switched out.
func (d Deps) ForLanguage(cfg DepsCfg, onCreated func(d *Deps) error) (*Deps, error) {
@@ -399,3 +407,30 @@ func (b *BuildState) Incr() int {
func NewBuildState() BuildState {
return BuildState{}
}
+
+type Closer interface {
+ Close() error
+}
+
+type Closers struct {
+ mu sync.Mutex
+ cs []Closer
+}
+
+func (cs *Closers) Add(c Closer) {
+ cs.mu.Lock()
+ defer cs.mu.Unlock()
+ cs.cs = append(cs.cs, c)
+}
+
+func (cs *Closers) Close() error {
+ cs.mu.Lock()
+ defer cs.mu.Unlock()
+ for _, c := range cs.cs {
+ c.Close()
+ }
+
+ cs.cs = cs.cs[:0]
+
+ return nil
+}