Skip to content

Instantly share code, notes, and snippets.

@emiltin
Created November 12, 2019 13:22
Show Gist options
  • Save emiltin/d6c0763aa4e11db167df618705daf71f to your computer and use it in GitHub Desktop.
Save emiltin/d6c0763aa4e11db167df618705daf71f to your computer and use it in GitHub Desktop.
Add submodule files to gemspec
gem_dir = Pathname.new(__dir__).expand_path
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
Dir.chdir(submodule_path) do
# for each submodule, cd to foler and get path relative to gem root folder
submodule_relative_path = Pathname.new(submodule_path).relative_path_from(gem_dir)
`git ls-files`.split($\).each do |filename|
# for each git file, prepend relative submodule path and add to spec
spec.files << submodule_relative_path.join(filename).to_s
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment