Skip to content

Commit

Permalink
(MODULES-8002) - Fix bundle commands not running in correct dir
Browse files Browse the repository at this point in the history
  • Loading branch information
eimlav committed Nov 12, 2018
1 parent f5e3edd commit ef2291e
Showing 1 changed file with 15 additions and 1 deletion.
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

0 comments on commit ef2291e

Please sign in to comment.