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

Fix cli default external encoding #332

Merged
merged 1 commit into from
Nov 6, 2020
Merged
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
33 changes: 24 additions & 9 deletions lib/bootsnap/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ def initialize(argv)
def precompile_command(*sources)
require 'bootsnap/compile_cache/iseq'

Bootsnap::CompileCache::ISeq.cache_dir = self.cache_dir
fix_default_encoding do
Bootsnap::CompileCache::ISeq.cache_dir = self.cache_dir

if compile_gemfile
sources += $LOAD_PATH
end
if compile_gemfile
sources += $LOAD_PATH
end

sources.map { |d| File.expand_path(d) }.each do |path|
if !exclude || !exclude.match?(path)
list_ruby_files(path).each do |ruby_file|
if !exclude || !exclude.match?(ruby_file)
CompileCache::ISeq.fetch(ruby_file, cache_dir: cache_dir)
sources.map { |d| File.expand_path(d) }.each do |path|
if !exclude || !exclude.match?(path)
list_ruby_files(path).each do |ruby_file|
if !exclude || !exclude.match?(ruby_file)
CompileCache::ISeq.fetch(ruby_file, cache_dir: cache_dir)
end
end
end
end
Expand Down Expand Up @@ -91,6 +93,19 @@ def run

private

def fix_default_encoding
if Encoding.default_external == Encoding::US_ASCII
Encoding.default_external = Encoding::UTF_8
begin
yield
ensure
Encoding.default_external = Encoding::US_ASCII
end
else
yield
end
end

def invalid_usage!(message)
STDERR.puts message
STDERR.puts
Expand Down