Skip to content

Commit 84da924

Browse files
committed
Add env option
1 parent 6a6017c commit 84da924

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ Ferrum::Browser.new(options)
183183
than this will cause a `Ferrum::DeadBrowserError`.
184184
* `:proxy` (Hash) - Specify proxy settings, [read more](https://github.com/rubycdp/ferrum#proxy)
185185
* `:save_path` (String) - Path to save attachments with [Content-Disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) header.
186+
* `:env` (Hash) - Environment variables you'd like to pass through to the process
186187

187188

188189
## Navigation

lib/ferrum/browser/process.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def initialize(options)
7373

7474
@logger = options[:logger]
7575
@process_timeout = options.fetch(:process_timeout, PROCESS_TIMEOUT)
76+
@env = Hash(options[:env])
7677

7778
tmpdir = Dir.mktmpdir("ferrum_user_data_dir_")
7879
ObjectSpace.define_finalizer(self, self.class.directory_remover(tmpdir))
@@ -95,7 +96,8 @@ def start
9596
ObjectSpace.define_finalizer(self, self.class.process_killer(@xvfb.pid))
9697
end
9798

98-
@pid = ::Process.spawn(Hash(@xvfb&.to_env), *@command.to_a, process_options)
99+
env = Hash(@xvfb&.to_env).merge(@env)
100+
@pid = ::Process.spawn(env, *@command.to_a, process_options)
99101
ObjectSpace.define_finalizer(self, self.class.process_killer(@pid))
100102

101103
parse_ws_url(read_io, @process_timeout)

0 commit comments

Comments
 (0)