Skip to content

Commit

Permalink
Handle Bun priting loaded env variables on STDERR
Browse files Browse the repository at this point in the history
Fix: #130
  • Loading branch information
byroot committed Sep 16, 2023
1 parent 6c1c228 commit cc6483c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/execjs/external_runtime.rb
Expand Up @@ -207,7 +207,7 @@ def exec_runtime(filename)
end
else
def exec_runtime(filename)
io = IO.popen(binary.split(' ') << filename, **(@popen_options.merge({err: [:child, :out]})))
io = IO.popen(binary.split(' ') << filename, **@popen_options)
output = io.read
io.close

Expand Down
10 changes: 10 additions & 0 deletions test/test_execjs.rb
Expand Up @@ -56,6 +56,16 @@ def test_call_with_complex_properties
assert_equal 2, context.call("(function(bar) { return foo + bar })", 1)
end

def test_call_with_env_file
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
# Bun prints on STDOUT when loading .env files
File.write(".env", "FOO=BAR")
assert_equal 2, ExecJS.eval("1 + 1")
end
end
end

def test_call_with_this
# Known bug: https://github.com/cowboyd/therubyrhino/issues/39
skip if ExecJS.runtime.is_a?(ExecJS::RubyRhinoRuntime)
Expand Down

0 comments on commit cc6483c

Please sign in to comment.