Commit 18f3588f authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: no colored output if machine-readable [GH-684]

parent a6d5ebaf
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment