-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
43 lines (38 loc) · 859 Bytes
/
Rakefile
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
42
43
require 'rainbow'
linters = [
{
name: 'ESLint',
language: 'JavaScript',
command: 'node_modules/.bin/eslint source/**/*.js'
},
{
name: 'stylelint',
language: 'CSS/SCSS',
command: 'stylelint **/*.scss'
},
{
name: 'RuboCop',
language: 'Ruby',
command: 'rubocop'
}
]
default_tasks = []
linters.each do |linter|
desc "Check your #{linter[:language]} files with #{linter[:name]}"
task linter[:name].downcase.to_sym do
puts Rainbow(
"Checking your #{linter[:language]} files with #{linter[:name]}..."
).bright.orange
run_linter(linter[:command])
end
default_tasks << linter[:name].downcase.to_sym
end
task default: default_tasks
def run_linter(command)
output = `#{command}`
if output.empty?
puts Rainbow('✔︎ Perfect style!').bright.green
else
system command
end
end