Sha256: f68ca67ba7a7f87dc059e3b25a9692a7a495465b8f178d72ed9a5b6b745d9f66
Contents?: true
Size: 1.53 KB
Versions: 4
Compression:
Stored size: 1.53 KB
Contents
require_relative "base" module Suspenders class StylelintGenerator < Generators::Base def setup_hound action InvokeGenerator.new(self, "suspenders:lint") action ToggleComments.new(self, ".hound.yml", /stylelintrc/) end def install_stylelint dependencies = ["stylelint", "@thoughtbot/stylelint-config"] action YarnInstall.new(self, dependencies, "--dev") end def copy_stylelint_config copy_file "stylelintrc.json", ".stylelintrc.json" end class InvokeGenerator def initialize(base, generator) @base = base @generator = generator end def invoke! @base.invoke @generator end def revoke! end end class ToggleComments def initialize(base, filename, pattern) @base = base @filename = filename @pattern = pattern end def invoke! @base.uncomment_lines(@filename, @pattern) end def revoke! @base.behavior = :invoke @base.comment_lines(@filename, @pattern) ensure @base.behavior = :revoke end end class YarnInstall def initialize(base, dependencies, flags) @base = base @dependencies = dependencies.join(" ") @flags = flags end def invoke! @base.run "bin/yarn add #{@dependencies} #{@flags}" end def revoke! @base.behavior = :invoke @base.run "bin/yarn remove #{@dependencies}" ensure @base.behavior = :revoke end end end end
Version data entries
4 entries across 4 versions & 1 rubygems