packer: no colored output if machine-readable [GH-684]
This commit is contained in:
parent
a6d5ebaf5e
commit
18f3588f35
|
@ -133,6 +133,13 @@ func wrappedMain() int {
|
|||
envConfig.Ui = &packer.MachineReadableUi{
|
||||
Writer: os.Stdout,
|
||||
}
|
||||
|
||||
// Set this so that we don't get colored output in our machine-
|
||||
// readable UI.
|
||||
if err := os.Setenv("PACKER_NO_COLOR", "1"); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Packer failed to initialize UI: %s\n", err)
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
env, err := packer.NewEnvironment(envConfig)
|
||||
|
|
|
@ -110,6 +110,11 @@ func (u *ColoredUi) colorize(message string, color UiColor, bold bool) string {
|
|||
}
|
||||
|
||||
func (u *ColoredUi) supportsColors() bool {
|
||||
// Never use colors if we have this environmental variable
|
||||
if os.Getenv("PACKER_NO_COLOR") != "" {
|
||||
return false
|
||||
}
|
||||
|
||||
// For now, on non-Windows machine, just assume it does
|
||||
if runtime.GOOS != "windows" {
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue