Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- a = File.read("./package.yaml")
- by_library = a.split(/(\nlibrary: *\n)/, 2)
- by_dependencies = by_library[2].split(/((?:^|\n) +dependencies: *\n)/, 2)
- dir = by_library[2].split(/((?:^|\n) +source-dirs: +)/, 2)[2].split("\n", 2)[0].strip
- by_dependencies[2] = by_dependencies[2].sub (/^(?:\n?( +)- [^\n]+\n)+/) do |m|
- `rg '^import(?: qualified)? "([^"]+)"' --replace='#{$1}- $1' --only-matching --type=haskell --no-filename --no-config --no-line-number --color=never #{dir} | sort -u`
- end
- a = [by_library[0..1], by_dependencies[0..2]].flatten.join ''
- File.write "./package.yaml", a
Add Comment
Please, Sign In to add comment