-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprettier.rb
More file actions
executable file
·35 lines (25 loc) · 1.1 KB
/
prettier.rb
File metadata and controls
executable file
·35 lines (25 loc) · 1.1 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
#!/usr/bin/env ruby
files_changed = `git diff --name-only`
files_changed_staged = `git diff --name-only --cached`
files_changed = files_changed.concat(files_changed_staged)
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 =~ /^app\/assets\// }
if consumer_files.size > 0
puts "prettying consumer changes"
`dc/exec widget yarn prettier -w #{consumer_files.map{ |f| f.gsub(/^consumer\//, "")}.join(" ")}`
end
if business_files.size > 0
puts "prettying business changes"
`dc/exec business yarn prettier -w #{business_files.map{ |f| f.gsub(/^business\//, "")}.join(" ")}`
end
if shared_files.size > 0
puts "prettying business changes"
`dc/exec widget yarn prettier -w #{shared_files.map{ |f| f.gsub(/^shared\//, "")}.join(" ")}`
end
if rails_files.size > 0
puts "prettying business changes"
`dc/exec test yarn prettier -w #{shared_files.map{ |f| f.gsub(/^app\/assets\//, "")}.join(" ")}`
end