Guest User

Untitled

a guest
May 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. a = File.read("./package.yaml")
  3. by_library = a.split(/(\nlibrary: *\n)/, 2)
  4.  
  5. by_dependencies = by_library[2].split(/((?:^|\n) +dependencies: *\n)/, 2)
  6.  
  7. dir = by_library[2].split(/((?:^|\n) +source-dirs: +)/, 2)[2].split("\n", 2)[0].strip
  8.  
  9. by_dependencies[2] = by_dependencies[2].sub (/^(?:\n?( +)- [^\n]+\n)+/) do |m|
  10. `rg '^import(?: qualified)? "([^"]+)"' --replace='#{$1}- $1' --only-matching --type=haskell --no-filename --no-config --no-line-number --color=never #{dir} | sort -u`
  11. end
  12.  
  13. a = [by_library[0..1], by_dependencies[0..2]].flatten.join ''
  14. File.write "./package.yaml", a
Add Comment
Please, Sign In to add comment