Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ gosec:
# NOTE: We can only exclude the import-text-template rule via a semgrep CLI flag
.PHONY: semgrep
semgrep:
if command -v semgrep &> /dev/null; then semgrep ci --config auto --exclude-rule go.lang.security.audit.xss.import-text-template.import-text-template; fi
if command -v semgrep &> /dev/null; then semgrep ci --config auto --exclude-rule go.lang.security.audit.xss.import-text-template.import-text-template $(SEMGREP_ARGS); fi

# Run third-party static analysis.
.PHONY: staticcheck
Expand Down
54 changes: 44 additions & 10 deletions pkg/commands/compute/language_toolchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,56 @@ func (bt BuildToolchain) Build() error {
text.Description(bt.out, "Build script to execute", fmt.Sprintf("%s %s", cmd, strings.Join(args, " ")))
}

var (
err error
msg string
)
var err error
msg := "Running [scripts.build]"

err = bt.spinner.Start()
if err != nil {
return err
// If we're in verbose mode, the build output is shown.
// So in that case we don't want to have a spinner as it'll interweave output.
// In non-verbose mode we have a spinner running while the build is happening.
if !bt.verbose {
err = bt.spinner.Start()
if err != nil {
return err
}
bt.spinner.Message(msg + "...")
}
msg = "Running [scripts.build]"
bt.spinner.Message(msg + "...")

err = bt.execCommand(cmd, args, msg)
if err != nil {
// In verbose mode we'll have the failure status AFTER the error output.
// But we can't just call StopFailMessage() without first starting the spinner.
if bt.verbose {
text.Break(bt.out)
err := bt.spinner.Start()
if err != nil {
return err
}
bt.spinner.Message(msg + "...")

bt.spinner.StopFailMessage(msg)
spinErr := bt.spinner.StopFail()
if spinErr != nil {
return spinErr
}
}
// WARNING: Don't try to add 'StopFailMessage/StopFail' calls here.
// It is handled internally by fstexec.Streaming.Exec().
// If we're in non-verbose mode, then the spiner is BEFORE the error output.
// Also, in non-verbose mode stopping the spinner is handled internally.
// See the call to StopFailMessage() inside fstexec.Streaming.Exec().
return bt.handleError(err)
}

// In verbose mode we'll have the failure status AFTER the error output.
// But we can't just call StopMessage() without first starting the spinner.
if bt.verbose {
err = bt.spinner.Start()
if err != nil {
return err
}
bt.spinner.Message(msg + "...")
text.Break(bt.out)
}

bt.spinner.StopMessage(msg)
err = bt.spinner.Stop()
if err != nil {
Expand Down Expand Up @@ -172,6 +203,9 @@ func (bt BuildToolchain) execCommand(cmd string, args []string, spinMessage stri
SpinnerMessage: spinMessage,
Verbose: bt.verbose,
}
if bt.verbose {
s.ForceOutput = true
}
if bt.timeout > 0 {
s.Timeout = time.Duration(bt.timeout) * time.Second
}
Expand Down
15 changes: 10 additions & 5 deletions pkg/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,16 @@ func (s *Streaming) Exec() error {
if err := cmd.Wait(); err != nil {
text.Output(output, divider)

if s.Spinner != nil {
s.Spinner.StopFailMessage(s.SpinnerMessage)
spinErr := s.Spinner.StopFail()
if spinErr != nil {
return spinErr
// If we're in verbose mode, the build output is shown.
// So in that case we don't want to have a spinner as it'll interweave output.
// In non-verbose mode we have a spinner running while the build is happening.
if !s.Verbose {
if s.Spinner != nil {
s.Spinner.StopFailMessage(s.SpinnerMessage)
spinErr := s.Spinner.StopFail()
if spinErr != nil {
return spinErr
}
}
}

Expand Down