feat(*): support perComandTimeout & variables in options

Signed-off-by: storyicon <yuanchao@bilibili.com>
This commit is contained in:
storyicon 2021-08-28 14:36:47 +08:00
parent 7b2c0762d4
commit 15047711a9
No known key found for this signature in database
GPG key ID: 245915D985F966CF
15 changed files with 302 additions and 122 deletions

View file

@ -117,9 +117,9 @@ func GetExitCode(err error) int {
var regexpEnvironmentVar = regexp.MustCompile(`\$[A-Za-z_]+`)
// RenderPathWithEnv is used to render path with environment
func RenderPathWithEnv(path string, ext map[string]string) string {
matches := regexpEnvironmentVar.FindAllString(path, -1)
// RenderWithEnv is used to render string with env
func RenderWithEnv(s string, ext map[string]string) string {
matches := regexpEnvironmentVar.FindAllString(s, -1)
for _, match := range matches {
key := match[1:]
val := ext[key]
@ -127,10 +127,15 @@ func RenderPathWithEnv(path string, ext map[string]string) string {
val = os.Getenv(key)
}
if val != "" {
path = strings.ReplaceAll(path, match, val)
s = strings.ReplaceAll(s, match, val)
}
}
return filepath.Clean(path)
return s
}
// RenderPathWithEnv is used to render path with environment
func RenderPathWithEnv(path string, ext map[string]string) string {
return filepath.Clean(RenderWithEnv(path, ext))
}
// SplitGoPackageVersion is used to split go package version