Last active
November 28, 2017 02:55
-
-
Save labocho/9adce7c0102034ba1db7d2b53f6af622 to your computer and use it in GitHub Desktop.
grep for all gems in Gemfile.lock
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
| #!/usr/bin/env ruby | |
| # Usage: bundle-grep -E "^foo" | |
| require "bundler" | |
| lockfile = Bundler::LockfileParser.new(File.read("Gemfile.lock")) | |
| gem_paths = lockfile.specs.map{|lazy_spec| lazy_spec.__materialize__.full_gem_path } | |
| command = ["find", *gem_paths, "-type", "f"].shelljoin + " | " + | |
| ["xargs", "grep", *ARGV].shelljoin | |
| exec(command) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment