Class: Inertia::Generators::JSPackageManager

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/inertia/install/js_package_manager.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(generator) ⇒ JSPackageManager

Returns a new instance of JSPackageManager.



10
11
12
# File 'lib/generators/inertia/install/js_package_manager.rb', line 10

def initialize(generator)
  @generator = generator
end

Class Method Details

.package_managersObject



6
7
8
# File 'lib/generators/inertia/install/js_package_manager.rb', line 6

def self.package_managers
  %w[npm yarn bun pnpm]
end

Instance Method Details

#add_dependencies(*dependencies) ⇒ Object



18
19
20
21
22
23
# File 'lib/generators/inertia/install/js_package_manager.rb', line 18

def add_dependencies(*dependencies)
  options = @generator.options[:verbose] ? '' : ' --silent'
  @generator.in_root do
    @generator.run "#{package_manager} add #{dependencies.join(' ')}#{options}"
  end
end

#present?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/generators/inertia/install/js_package_manager.rb', line 14

def present?
  package_manager.present?
end