Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect NO_COLOR environment variable #105

Merged
merged 2 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions lib/irb/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def IRB.init_config(ap_path)
@CONF[:IRB_RC] = nil

@CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
@CONF[:USE_COLORIZE] = true
@CONF[:USE_COLORIZE] = !ENV['NO_COLOR']
@CONF[:INSPECT_MODE] = true
@CONF[:USE_TRACER] = false
@CONF[:USE_LOADER] = false
Expand Down Expand Up @@ -224,11 +224,11 @@ def IRB.parse_opts(argv: ::ARGV)
break
end
end

load_path.collect! do |path|
/\A\.\// =~ path ? path : File.expand_path(path)
end
$LOAD_PATH.unshift(*load_path)

end

# running config
Expand Down
16 changes: 16 additions & 0 deletions test/irb/test_init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ def test_rc_file_in_subdir
ENV["IRBRC"] = backup_irbrc
end

def test_no_color_environment_variable
orig = ENV['NO_COLOR']

assert IRB.conf[:USE_COLORIZE]

ENV['NO_COLOR'] = 'true'
IRB.setup(eval("__FILE__"))
refute IRB.conf[:USE_COLORIZE]

ENV['NO_COLOR'] = nil
IRB.setup(eval("__FILE__"))
assert IRB.conf[:USE_COLORIZE]
jethrodaniel marked this conversation as resolved.
Show resolved Hide resolved
ensure
ENV['NO_COLOR'] = orig
end

private

def with_argv(argv)
Expand Down