Forked from mattconnolly/gem-with-git-submodules.gemspec
Created
December 25, 2022 03:11
-
-
Save initdc/af23b51fe90630cc0e764772a881a578 to your computer and use it in GitHub Desktop.
Gem Spec support for git submodules inside a gem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Gem::Specification.new do |s| | |
| # normal spec stuff above | |
| s.files = `git ls-files`.split("\n") | |
| # get an array of submodule dirs by executing 'pwd' inside each submodule | |
| gem_dir = File.expand_path(File.dirname(__FILE__)) + "/" | |
| `git submodule --quiet foreach pwd`.split($\).each do |submodule_path| | |
| Dir.chdir(submodule_path) do | |
| submodule_relative_path = submodule_path.sub gem_dir, "" | |
| # issue git ls-files in submodule's directory and | |
| # prepend the submodule path to create absolute file paths | |
| `git ls-files`.split($\).each do |filename| | |
| s.files << "#{submodule_relative_path}/#{filename}" | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment