-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprettier-check.rb
More file actions
executable file
·53 lines (43 loc) · 1.51 KB
/
prettier-check.rb
File metadata and controls
executable file
·53 lines (43 loc) · 1.51 KB
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
44
45
46
47
48
49
50
#!/usr/bin/env ruby
files_changed = `git diff --name-only --cached`
files_changed = files_changed.split("\n")
consumer_files = files_changed.select{ |f| f =~ /^consumer/ }
business_files = files_changed.select{ |f| f =~ /^business/ }
shared_files = files_changed.select{ |f| f =~ /^shared/ }
rails_files = files_changed.select{ |f| f =~ /^rails\/app\/assets\// }
if consumer_files.size > 0
puts "prettying consumer changes"
output = `dc/exec widget yarn prettier --check #{consumer_files.map{ |f| f.gsub(/^consumer\//, "")}.join(" ")}`
if $?.exitstatus == 1
puts output
puts "Run ~/.dotfiles/prettier.rb to cleanup the files"
exit 1
end
end
if business_files.size > 0
puts "prettying business changes"
puts `dc/exec business yarn prettier --check #{business_files.map{ |f| f.gsub(/^business\//, "")}.join(" ")}`
if $?.exitstatus == 1
puts output
puts "Run ~/.dotfiles/prettier.rb to cleanup the files"
exit 1
end
end
if shared_files.size > 0
puts "prettying shared changes"
puts `dc/exec business yarn prettier --check #{shared_files.map{ |f| f.gsub(/^shared\//, "")}.join(" ")}`
if $?.exitstatus == 1
puts output
puts "Run ~/.dotfiles/prettier.rb to cleanup the files"
exit 1
end
end
if rails_files.size > 0
puts "prettying shared changes"
puts `dc/exec test yarn prettier --check #{rails_files.map{ |f| f.gsub(/^app\/assets/, "")}.join(" ")}`
if $?.exitstatus == 1
puts output
puts "Run ~/.dotfiles/prettier.rb to cleanup the files"
exit 1
end
end