Sha256: 418d133dfcacd749cb0f080d17db26cce68987b72049e44b2a750251f811dac9

Contents?: true

Size: 2 KB

Versions: 15

Compression:

Stored size: 2 KB

Contents

module Puppeteer::Launcher
  class Base
    # @param {string} projectRoot
    # @param {string} preferredRevision
    def initialize(project_root:, preferred_revision:, is_puppeteer_core:)
      @project_root = project_root
      @preferred_revision = preferred_revision
      @is_puppeteer_core = is_puppeteer_core
    end

    class ExecutablePathNotFound < StandardError; end

    # @returns [String] Chrome Executable file path.
    # @raise [ExecutablePathNotFound]
    def resolve_executable_path
      if !@is_puppeteer_core
        # puppeteer-core doesn't take into account PUPPETEER_* env variables.
        executable_path = ENV['PUPPETEER_EXECUTABLE_PATH']
        if FileTest.exist?(executable_path)
          return executable_path
        end
        raise ExecutablePathNotFound.new(
          "Tried to use PUPPETEER_EXECUTABLE_PATH env variable to launch browser but did not find any executable at: #{executablePath}",
        )
      end

      # temporal logic.
      if RUBY_PLATFORM.include?('darwin') # MacOS
        '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
      else
        '/usr/bin/google-chrome'
      end

      # const browserFetcher = new BrowserFetcher(launcher._projectRoot);
      # if (!launcher._isPuppeteerCore) {
      #   const revision = process.env['PUPPETEER_CHROMIUM_REVISION'];
      #   if (revision) {
      #     const revisionInfo = browserFetcher.revisionInfo(revision);
      #     const missingText = !revisionInfo.local ? 'Tried to use PUPPETEER_CHROMIUM_REVISION env variable to launch browser but did not find executable at: ' + revisionInfo.executablePath : null;
      #     return {executablePath: revisionInfo.executablePath, missingText};
      #   }
      # }
      # const revisionInfo = browserFetcher.revisionInfo(launcher._preferredRevision);
      # const missingText = !revisionInfo.local ? `Browser is not downloaded. Run "npm install" or "yarn install"` : null;
      # return {executablePath: revisionInfo.executablePath, missingText};
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
puppeteer-ruby-0.0.18 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.17 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.16 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.15 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.14 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.13 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.12 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.11 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.10 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.9 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.8 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.6 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.5 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.4 lib/puppeteer/launcher/base.rb
puppeteer-ruby-0.0.3 lib/puppeteer/launcher/base.rb