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 PathReader when a file is missing #2044

Merged
merged 2 commits into from Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 2 additions & 10 deletions lib/opal/builder.rb
Expand Up @@ -195,16 +195,8 @@ def process_require(rel_path, options)

source = stub?(rel_path) ? '' : read(rel_path)

if source.nil?
message = "can't find file: #{rel_path.inspect}"
case missing_require_severity
when :error then raise LoadError, message
when :warning then warn "can't find file: #{rel_path.inspect}"
when :ignore then # noop
end

return # the handling is delegated to the runtime
end
# The handling is delegated to the runtime
return if source.nil?

abs_path = expand_path(rel_path)
rel_path = expand_ext(rel_path)
Expand Down
2 changes: 1 addition & 1 deletion lib/opal/path_reader.rb
Expand Up @@ -17,7 +17,7 @@ def initialize(paths = Opal.paths, extensions = DEFAULT_EXTENSIONS)
def read(path)
full_path = expand(path)
return nil if full_path.nil?
File.open(full_path, 'rb:UTF-8', &:read)
File.open(full_path, 'rb:UTF-8', &:read) if File.exist?(full_path)
end

def expand(path)
Expand Down