Skip to content

Commit 48e4ece

Browse files
authored
local backend make cmd log output similar to other shells (#2678)
the cmd currently shows the full prompt and drop the exact error level. this set the prompt to be hidden and let cmd exit with error level reported by the command --- *Sponsored by Kithara Software GmbH*
1 parent 4647e64 commit 48e4ece

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
"eslint.workingDirectories": ["./web"],
1212
"prettier.configPath": "./web/.prettierrc.js",
1313
"prettier.ignorePath": "./web/.prettierignore",
14-
"cSpell.words": ["Curr", "doublestar", "multierr"]
14+
"cSpell.words": ["Curr", "doublestar", "ERRORLEVEL", "multierr"]
1515
}

pipeline/backend/local/command.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ func genCmdByShell(shell string, cmds []string) (args []string, err error) {
3131

3232
switch strings.TrimSuffix(strings.ToLower(shell), ".exe") {
3333
case "cmd":
34-
script := ""
34+
script := "@SET PROMPT=$\n"
3535
for _, cmd := range cmds {
36-
script += fmt.Sprintf("%s || exit 1\n", cmd)
36+
script += fmt.Sprintf("@echo + %s\n", strings.TrimSpace(shellescape.Quote(cmd)))
37+
script += fmt.Sprintf("@%s\n", cmd)
38+
script += "@IF NOT %ERRORLEVEL% == 0 exit %ERRORLEVEL%\n"
3739
}
3840
cmd, err := os.CreateTemp(os.TempDir(), "*.cmd")
3941
if err != nil {

0 commit comments

Comments
 (0)