Class: Suspenders::StylelintGenerator::YarnInstall

Inherits:
Object
  • Object
show all
Defined in:
lib/suspenders/generators/stylelint_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(base, dependencies, flags) ⇒ YarnInstall

Returns a new instance of YarnInstall.



21
22
23
24
25
# File 'lib/suspenders/generators/stylelint_generator.rb', line 21

def initialize(base, dependencies, flags)
  @base = base
  @dependencies = dependencies
  @flags = flags
end

Instance Method Details

#invoke!Object



27
28
29
30
# File 'lib/suspenders/generators/stylelint_generator.rb', line 27

def invoke!
  dependencies_with_versions = @dependencies.map { |d| d[:version] ? "#{d[:name]}@#{d[:version]}" : d[:name] }.join(' ')
  @base.run "bin/yarn add #{dependencies_with_versions} #{@flags}"
end

#revoke!Object



32
33
34
35
36
37
# File 'lib/suspenders/generators/stylelint_generator.rb', line 32

def revoke!
  @base.behavior = :invoke
  @base.run "bin/yarn remove #{@dependencies.map { |d| d[:name] }.join(' ')}"
ensure
  @base.behavior = :revoke
end