Skip to content

Commit

Permalink
Add env option
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed May 25, 2022
1 parent 6a6017c commit 84da924
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ Ferrum::Browser.new(options)
than this will cause a `Ferrum::DeadBrowserError`.
* `:proxy` (Hash) - Specify proxy settings, [read more](https://github.com/rubycdp/ferrum#proxy)
* `:save_path` (String) - Path to save attachments with [Content-Disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) header.
* `:env` (Hash) - Environment variables you'd like to pass through to the process


## Navigation
Expand Down
4 changes: 3 additions & 1 deletion lib/ferrum/browser/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def initialize(options)

@logger = options[:logger]
@process_timeout = options.fetch(:process_timeout, PROCESS_TIMEOUT)
@env = Hash(options[:env])

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

@pid = ::Process.spawn(Hash(@xvfb&.to_env), *@command.to_a, process_options)
env = Hash(@xvfb&.to_env).merge(@env)
@pid = ::Process.spawn(env, *@command.to_a, process_options)
ObjectSpace.define_finalizer(self, self.class.process_killer(@pid))

parse_ws_url(read_io, @process_timeout)
Expand Down

0 comments on commit 84da924

Please sign in to comment.