Class: EmbeddedJs::Commands::Preinstall

Inherits:
Object
  • Object
show all
Defined in:
lib/embedded_js/commands/preinstall.rb

Constant Summary collapse

ENV_VARIABLE_NAME =
'EP_PREINSTALL'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_runner: Adaptors::CommandRunner.new, package_manager: PackageManagers::Factory.build(EmbeddedJs.config.package_manager)) ⇒ Preinstall

Returns a new instance of Preinstall.



18
19
20
21
22
23
24
# File 'lib/embedded_js/commands/preinstall.rb', line 18

def initialize(
  command_runner: Adaptors::CommandRunner.new,
  package_manager: PackageManagers::Factory.build(EmbeddedJs.config.package_manager)
)
  @command_runner = command_runner
  @package_manager = package_manager
end

Class Method Details

.call(gems:) ⇒ Object



13
14
15
# File 'lib/embedded_js/commands/preinstall.rb', line 13

def call(gems:)
  new.call(gems: gems)
end

Instance Method Details

#call(gems:) ⇒ Object



26
27
28
29
30
# File 'lib/embedded_js/commands/preinstall.rb', line 26

def call(gems:)
  return if ENV.fetch(ENV_VARIABLE_NAME, nil)

  gems.each(&method(:install_embedded_package))
end