Sha256: 6f1b263dc2fb32d353db75f8c109fa3518e79c2ce834feb49a2729ce86fe7f95

Contents?: true

Size: 1.01 KB

Versions: 18

Compression:

Stored size: 1.01 KB

Contents

require 'rake'
require 'rake/tasklib'

module SCSSLint
  # Provide task for invoking scss-lint via Rake.
  #
  # @example
  #   require 'scss_lint/rake_task'
  #   SCSSLint::RakeTask.new
  class RakeTask < Rake::TaskLib
    # The name of the task (default 'scss-lint')
    attr_accessor :name

    def initialize(*args, &task_block)
      @name = args.shift || :scss_lint

      desc 'Run scss-lint' unless ::Rake.application.last_comment

      task(name, *args) do |_, task_args|
        if task_block
          task_block.call(*[self, task_args].slice(0, task_block.arity))
        end
        run_task
      end
    end

    def run_task
      # Lazy load so task doesn't impact load time of Rakefile
      require 'scss_lint'

      CLI.new([]).tap do |cli|
        cli.parse_arguments
        cli.run
      end
    rescue SystemExit => ex
      if ex.status == CLI::EXIT_CODES[:data]
        abort('scss-lint found lints')
      elsif ex.status != 0
        abort('scss-lint failed with an error')
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
scss-lint-0.29.0 lib/scss_lint/rake_task.rb
scss-lint-0.28.0 lib/scss_lint/rake_task.rb
scss-lint-0.27.0 lib/scss_lint/rake_task.rb
scss-lint-0.26.2 lib/scss_lint/rake_task.rb
scss-lint-0.26.1 lib/scss_lint/rake_task.rb
scss-lint-0.26.0 lib/scss_lint/rake_task.rb
scss-lint-0.25.1 lib/scss_lint/rake_task.rb
scss-lint-0.25.0 lib/scss_lint/rake_task.rb
scss-lint-0.24.1 lib/scss_lint/rake_task.rb
scss-lint-0.24.0 lib/scss_lint/rake_task.rb
scss-lint-0.23.1 lib/scss_lint/rake_task.rb
scss-lint-0.23.0 lib/scss_lint/rake_task.rb
scss-lint-0.22.0 lib/scss_lint/rake_task.rb
scss-lint-0.21.0 lib/scss_lint/rake_task.rb
scss-lint-0.20.3 lib/scss_lint/rake_task.rb
scss-lint-0.20.2 lib/scss_lint/rake_task.rb
scss-lint-0.20.1 lib/scss_lint/rake_task.rb
scss-lint-0.20.0 lib/scss_lint/rake_task.rb