File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,14 @@ func ParseArgs(command string) (params []string) {
175
175
return
176
176
}
177
177
178
+ func ParseEnvVar (v string ) string {
179
+ return envOS .ReplaceAllStringFunc (v , getEnv )
180
+ }
181
+
182
+ func ParseWindowsEnvVar (v string ) string {
183
+ return envWin .ReplaceAllStringFunc (v , getWinEnv )
184
+ }
185
+
178
186
func getWinEnv (s string ) string {
179
187
s = strings .TrimPrefix (s , `{%` )
180
188
s = strings .TrimSuffix (s , `%}` )
Original file line number Diff line number Diff line change
1
+ package com
2
+
3
+ import (
4
+ "os"
5
+ "testing"
6
+
7
+ "github.com/stretchr/testify/assert"
8
+ )
9
+
10
+ func TestParseEnvVar (t * testing.T ) {
11
+ os .Setenv (`TESTENV` , `1` )
12
+ v := ParseEnvVar (`ab{$TESTENV}c` )
13
+ assert .Equal (t , `ab1c` , v )
14
+ }
15
+
16
+ func TestParseWindowsEnvVar (t * testing.T ) {
17
+ os .Setenv (`TESTENV` , `2` )
18
+ v := ParseWindowsEnvVar (`ab{%TESTENV%}c` )
19
+ assert .Equal (t , `ab2c` , v )
20
+ }
You can’t perform that action at this time.
0 commit comments