summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-02-19 21:05:23 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-02-19 21:05:23 +0100
commite9e20b21f426eef0a8a49042d6d76ba7aa576085 (patch)
tree5e514711e03620626b8e6dc7c668d8b511f8ec54
parentab6de4043c08ca67a03e24b157a14bae3cf5f914 (diff)
downloadbundler-e9e20b21f426eef0a8a49042d6d76ba7aa576085.tar.gz
Stop switching folders in `bundle gem` and `bundle cli`
-rw-r--r--lib/bundler/cli/gem.rb7
-rw-r--r--lib/bundler/cli/open.rb10
2 files changed, 7 insertions, 10 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index 00b3bc55a6..e1600d8e67 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -166,10 +166,9 @@ module Bundler
if Bundler.git_present? && options[:git]
Bundler.ui.info "Initializing git repo in #{target}"
- Dir.chdir(target) do
- `git init`
- `git add .`
- end
+ require "open3"
+ Open3.capture2e("git", "init", :chdir => target)
+ Open3.capture2e("git", "add", ".", :chdir => target)
end
# Open gemspec in editor
diff --git a/lib/bundler/cli/open.rb b/lib/bundler/cli/open.rb
index df32e2f38b..c8fe561ffb 100644
--- a/lib/bundler/cli/open.rb
+++ b/lib/bundler/cli/open.rb
@@ -18,12 +18,10 @@ module Bundler
Bundler.ui.info "Unable to open #{name} because it's a default gem, so the directory it would normally be installed to does not exist."
else
path = spec.full_gem_path
- Dir.chdir(path) do
- command = Shellwords.split(editor) + [path]
- Bundler.with_original_env do
- system(*command)
- end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
- end
+ command = Shellwords.split(editor) + [path]
+ Bundler.with_original_env do
+ system(*command, :chdir => path)
+ end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
end
end
end