agent: pi-magpie's source pattern compiles on first use (TestNoEagerPackageRegexps)
d52e2feafadded piMagpieExt as a package-level regexp.MustCompile, so TestNoEagerPackageRegexps in the root package was red on main ("internal/agent/pimagpie.go:13:19: a package-level regexp is compiled at launch; use lazyre.New"). It is lazyre.New now, as the rest of internal/agent's patterns are. Run on mica: go test -run TestNoEagerPackageRegexps . ok (red before, in the full suite at70f4593e6); go test -run Pi ./internal/agent ok; go vet ./internal/agent ok; gofmt clean.
This commit is contained in:
@@ -3,14 +3,14 @@ package agent
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
"github.com/yetone/magpie/internal/lazyre"
|
||||
)
|
||||
|
||||
// piMagpieExt matches a Pi package source for the pi-magpie extension:
|
||||
// npm:pi-magpie, npm:pi-magpie@0.1.6, or a path or git source ending in it.
|
||||
var piMagpieExt = regexp.MustCompile(`(^|[:/\\])pi-magpie(@[^/\\]*)?(#.*)?$`)
|
||||
var piMagpieExt = lazyre.New(`(^|[:/\\])pi-magpie(@[^/\\]*)?(#.*)?$`)
|
||||
|
||||
// piMagpieInstalled says Pi's settings.json lists the pi-magpie extension
|
||||
// in "packages". It serves provider "magpie" from magpie's live catalog,
|
||||
|
||||
Reference in New Issue
Block a user