Add helper option for setting custom module path on PowerShell executes

This commit is contained in:
Chris Roberts 2018-06-12 10:44:12 -07:00
parent 4efec92643
commit 5325000fa6
1 changed files with 18 additions and 6 deletions

View File

@ -54,8 +54,12 @@ module Vagrant
if opts.delete(:sudo) || opts.delete(:runas)
powerup_command(path, args, opts)
else
env = opts.delete(:env)
if env
if mpath = opts.delete(:module_path)
m_env = opts.fetch(:env, {})
m_env["PSModulePath"] = "$env:PSModulePath+';#{mpath}'"
opts[:env] = m_env
end
if env = opts.delete(:env)
env = env.map{|k,v| "$env:#{k}=#{v}"}.join(";") + "; "
end
command = [
@ -85,8 +89,12 @@ module Vagrant
# Returns stdout string if exit code is zero.
def self.execute_cmd(command, **opts)
validate_install!
env = opts.delete(:env)
if env
if mpath = opts.delete(:module_path)
m_env = opts.fetch(:env, {})
m_env["PSModulePath"] = "$env:PSModulePath+';#{mpath}'"
opts[:env] = m_env
end
if env = opts.delete(:env)
env = env.map{|k,v| "$env:#{k}=#{v}"}.join(";") + "; "
end
c = [
@ -112,8 +120,12 @@ module Vagrant
# @param [Block] block Ruby block
def self.execute_inline(*command, **opts, &block)
validate_install!
env = opts.delete(:env)
if env
if mpath = opts.delete(:module_path)
m_env = opts.fetch(:env, {})
m_env["PSModulePath"] = "$env:PSModulePath+';#{mpath}'"
opts[:env] = m_env
end
if env = opts.delete(:env)
env = env.map{|k,v| "$env:#{k}=#{v}"}.join(";") + "; "
end
c = [