From cea157402365f34a69882110a4208999728007a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 23 Dec 2020 09:26:23 +0100 Subject: 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 --- deps/deps.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'deps') 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 +} -- cgit v1.2.3