forked from sds/scss-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrake_task.rb
41 lines (35 loc) · 999 Bytes
/
rake_task.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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'
require 'scss_lint/cli'
CLI.new.run([])
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