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

Handle Bun priting loaded env variables on STDERR #131

Merged
merged 1 commit into from Sep 16, 2023
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
4 changes: 2 additions & 2 deletions lib/execjs/external_runtime.rb
Expand Up @@ -194,7 +194,7 @@ def shell_escape(*args)
require 'shellwords'

def exec_runtime(filename)
command = "#{Shellwords.join(binary.split(' ') << filename)} 2>&1"
command = "#{Shellwords.join(binary.split(' ') << filename)}"
io = IO.popen(command, **@popen_options)
output = io.read
io.close
Expand All @@ -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