improve powershell script generation

pull/1/head
Brad Rydzewski 5 years ago
parent 833e424937
commit 8ab777d822

@ -29,8 +29,8 @@ func Command() (string, []string) {
func Script(commands []string) string {
var buf bytes.Buffer
for _, command := range commands {
escaped := fmt.Sprintf("%q", command)
escaped = strings.Replace(escaped, "$", `\$`, -1)
escaped := fmt.Sprintf("%q", "+ "+command)
escaped = strings.Replace(escaped, "$", "`$", -1)
buf.WriteString(fmt.Sprintf(
traceScript,
escaped,
@ -53,6 +53,6 @@ $erroractionpreference = "stop"
// traceScript is a helper script that is added to
// the build script to trace a command.
const traceScript = `
Write-Output ('+ %s');
& %s; if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
echo %s
%s
`

@ -39,10 +39,10 @@ func TestScript(t *testing.T) {
var exampleScript = `
$erroractionpreference = "stop"
Write-Output ('+ "go build"');
& go build; if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
echo "+ go build"
go build
Write-Output ('+ "go test"');
& go test; if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
echo "+ go test"
go test
`

Loading…
Cancel
Save