mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-07-02 21:52:51 +08:00
chore(cmd): trim space in command
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
648e3c1321
commit
9b57f85e47
@ -195,6 +195,9 @@ func (p Plugin) scriptCommands() []string {
|
||||
commands := make([]string, 0)
|
||||
|
||||
for _, cmd := range scripts {
|
||||
if strings.TrimSpace(cmd) == "" {
|
||||
continue
|
||||
}
|
||||
commands = append(commands, cmd)
|
||||
if p.Config.ScriptStop {
|
||||
commands = append(commands, "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;")
|
||||
|
@ -569,6 +569,16 @@ func TestPlugin_scriptCommands(t *testing.T) {
|
||||
},
|
||||
want: []string{"mkdir a", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;", "mkdir c", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;", "mkdir b", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;"},
|
||||
},
|
||||
{
|
||||
name: "trim space",
|
||||
fields: fields{
|
||||
Config: Config{
|
||||
Script: []string{"mkdir a", "mkdir b", "\t", " "},
|
||||
ScriptStop: false,
|
||||
},
|
||||
},
|
||||
want: []string{"mkdir a", "mkdir b"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user