Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-8002) - Fix bundle commands not running in correct dir #79

Merged
merged 1 commit into from
Nov 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/pdksync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require 'json'
require 'yaml'
require 'colorize'
require 'bundler'

# @summary
# This module set's out and controls the pdksync process
Expand Down Expand Up @@ -263,8 +264,21 @@ def self.clone_directory(namespace, module_name, output_path)
# @return [Integer]
# The status code of the command run.
def self.run_command(output_path, command)
stdout = ''
stderr = ''
status = Process::Status

Dir.chdir(output_path) unless Dir.pwd == output_path
stdout, stderr, status = Open3.capture3(command)

# Environment cleanup required due to Ruby subshells using current Bundler environment
if command =~ %r{^bundle}
Bundler.with_clean_env do
stdout, stderr, status = Open3.capture3(command)
end
else
stdout, stderr, status = Open3.capture3(command)
end

puts "\n#{stdout}\n".yellow
puts "(FAILURE) Unable to run command '#{command}': #{stderr}".red unless status.exitstatus.zero?
status.exitstatus
Expand Down