MCPcopy Index your code
hub / github.com/devspace-sh/devspace / executeCommandWithAfter

Function executeCommandWithAfter

cmd/run.go:174–199  ·  view source on GitHub ↗
(ctx context.Context, command *latest.CommandConfig, args []string, variables map[string]interface{}, dir string, stdout io.Writer, stderr io.Writer, stdin io.Reader, log log.Logger)

Source from the content-addressed store, hash-verified

172}
173
174func executeCommandWithAfter(ctx context.Context, command *latest.CommandConfig, args []string, variables map[string]interface{}, dir string, stdout io.Writer, stderr io.Writer, stdin io.Reader, log log.Logger) error {
175 originalErr := interrupt.Global.Run(func() error {
176 return ExecuteCommand(ctx, command, variables, args, dir, stdout, stderr, stdin)
177 }, func() {
178 if command.After != "" {
179 vars := variables
180 vars["COMMAND_INTERRUPT"] = "true"
181 err := executeShellCommand(ctx, command.After, vars, args, dir, stdout, stderr, stdin)
182 if err != nil {
183 log.Errorf("error executing after command: %v", err)
184 }
185 }
186 })
187 if command.After != "" {
188 vars := variables
189 if originalErr != nil {
190 vars["COMMAND_ERROR"] = originalErr.Error()
191 }
192 err := executeShellCommand(ctx, command.After, vars, args, dir, stdout, stderr, stdin)
193 if err != nil {
194 return errors.Wrap(err, "error executing after command")
195 }
196 }
197
198 return originalErr
199}
200
201func ParseArgs(cobraCmd *cobra.Command, globalFlags *flags.GlobalFlags, log log.Logger) ([]string, error) {
202 index := -1

Callers 1

RunRunMethod · 0.85

Calls 5

ExecuteCommandFunction · 0.85
executeShellCommandFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected