Sha256: 9babd24b1650f87bc179640857b800e9e3b4fbe6267c4f9deb3103642adad7d8

Contents?: true

Size: 961 Bytes

Versions: 4

Compression:

Stored size: 961 Bytes

Contents

require_relative "base"

module Suspenders
  class StylelintGenerator < Generators::Base
    def install_stylelint
      dependencies = ["stylelint",
                      "stylelint-config-recommended",
                      "stylelint-order",
                      "stylelint-declaration-block-no-ignored-properties",
                      "stylelint-scss"]
      action YarnInstall.new(self, dependencies, "--dev")
    end

    def copy_stylelint_config
      copy_file "stylelintrc.json", ".stylelintrc.json"
    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

Version Path
welaika-suspenders-2.33 lib/suspenders/generators/stylelint_generator.rb
welaika-suspenders-2.32.2 lib/suspenders/generators/stylelint_generator.rb
welaika-suspenders-2.32.1 lib/suspenders/generators/stylelint_generator.rb
welaika-suspenders-2.32.0 lib/suspenders/generators/stylelint_generator.rb