rollback including envs in shell script

pull/1/head
Brad Rydzewski 5 years ago
parent a8307ea13b
commit 8449fe8013

@ -26,12 +26,8 @@ func Command() (string, []string) {
// Script converts a slice of individual shell commands to
// a powershell script.
func Script(commands []string, environ map[string]string) string {
func Script(commands []string) string {
buf := new(bytes.Buffer)
for k, v := range environ {
fmt.Fprintln(buf)
fmt.Fprintf(buf, exportScript, k, v)
}
fmt.Fprintln(buf)
fmt.Fprintf(buf, optionScript)
fmt.Fprintln(buf)
@ -51,10 +47,6 @@ func Script(commands []string, environ map[string]string) string {
// to set shell options, in this case, to exit on error.
const optionScript = `$erroractionpreference = "stop"`
// exportScript is a helper script that is added to
// the build script to export environment variables.
const exportScript = "$Env:%s = %q"
// traceScript is a helper script that is added to
// the build script to trace a command.
const traceScript = `

@ -30,15 +30,7 @@ func TestCommands(t *testing.T) {
}
func TestScript(t *testing.T) {
got, want := Script([]string{"go build", "go test"}, nil), exampleScript
if got != want {
t.Errorf("Want %q, got %q", want, got)
}
}
func TestScriptEnviron(t *testing.T) {
env := map[string]string{"GOOS": "linux"}
got, want := Script([]string{"go build", "go test"}, env), exampleScriptEnviron
got, want := Script([]string{"go build", "go test"}), exampleScript
if got != want {
t.Errorf("Want %q, got %q", want, got)
}
@ -53,14 +45,3 @@ go build
echo "+ go test"
go test
`
var exampleScriptEnviron = `
$Env:GOOS = "linux"
$erroractionpreference = "stop"
echo "+ go build"
go build
echo "+ go test"
go test
`

@ -25,12 +25,8 @@ func Command() (string, []string) {
// Script converts a slice of individual shell commands to
// a posix-compliant shell script.
func Script(commands []string, environ map[string]string) string {
func Script(commands []string) string {
buf := new(bytes.Buffer)
for k, v := range environ {
fmt.Fprintln(buf)
fmt.Fprintf(buf, exportScript, k, v)
}
fmt.Fprintln(buf)
fmt.Fprintf(buf, optionScript)
fmt.Fprintln(buf)
@ -50,10 +46,6 @@ func Script(commands []string, environ map[string]string) string {
// to set shell options, in this case, to exit on error.
const optionScript = "set -e"
// exportScript is a helper script that is added to
// the build script to export environment variables.
const exportScript = "export %s=%q"
// traceScript is a helper script that is added to
// the build script to trace a command.
const traceScript = `

@ -28,15 +28,7 @@ func TestCommands(t *testing.T) {
}
func TestScript(t *testing.T) {
got, want := Script([]string{"go build", "go test"}, nil), exampleScript
if got != want {
t.Errorf("Want %q, got %q", want, got)
}
}
func TestScriptEnviron(t *testing.T) {
env := map[string]string{"GOOS": "linux"}
got, want := Script([]string{"go build", "go test"}, env), exampleScriptEnviron
got, want := Script([]string{"go build", "go test"}), exampleScript
if got != want {
t.Errorf("Want %q, got %q", want, got)
}
@ -51,14 +43,3 @@ go build
echo + "go test"
go test
`
var exampleScriptEnviron = `
export GOOS="linux"
set -e
echo + "go build"
go build
echo + "go test"
go test
`

@ -18,6 +18,6 @@ func Command() (string, []string) {
// Script converts a slice of individual shell commands to
// a powershell script.
func Script(commands []string, environ map[string]string) string {
return powershell.Script(commands, environ)
func Script(commands []string) string {
return powershell.Script(commands)
}

Loading…
Cancel
Save