diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-12-23 09:26:23 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-12-30 17:32:25 +0100 |
commit | cea157402365f34a69882110a4208999728007a6 (patch) | |
tree | bc29f699e7c901c219cffc5f50fba99dca53d5bd /deps/deps.go | |
parent | f9f779786edcefc4449a14cfc04dd93379f71373 (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/deps.go')
-rw-r--r-- | deps/deps.go | 35 |
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 +} |