Skip to content

Commit 01d0c61

Browse files
committed
Support JULIA_CAPTURE_COLOR environment variable
1 parent 47669d1 commit 01d0c61

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/workflows.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,18 @@ function optimize_or_load(
231231
verbose,
232232
_else=_print_loaded_output
233233
) do
234+
color = get(stdout, :color, false)
235+
if haskey(ENV, "JULIA_CAPTURE_COLOR")
236+
# Undocumented feature. Literate.jl doesn't work well with captured
237+
# color. When doing an optimization in a Literate example, it's
238+
# best to evaluate it with JULIA_CAPTURE_COLOR=0
239+
color = (ENV["JULIA_CAPTURE_COLOR"] != "0")
240+
end
234241
if isnothing(logfile)
235242
c = IOCapture.capture(
236243
passthrough=true,
237244
capture_buffer=FirstLastBuffer(),
238-
color=get(stdout, :color, false)
245+
color=color,
239246
) do
240247
optimize(problem; method, verbose, atexit_filename, kwargs...)
241248
end

0 commit comments

Comments
 (0)