Added mkdir command filter for WinRM to be compatible with PS4+

This commit is contained in:
Richard Guin 2014-07-30 15:43:11 -04:00
parent 89beb695f2
commit 361d41527a
2 changed files with 26 additions and 0 deletions

View File

@ -11,6 +11,7 @@ module VagrantPlugins
"test",
"uname",
"which",
"mkdir",
]
# Filter the given Vagrant command to ensure compatibility with Windows

View File

@ -0,0 +1,25 @@
module VagrantPlugins
module CommunicatorWinRM
module CommandFilters
# Converts a *nix 'mkdir' command to a PowerShell equivalent
class Mkdir
def filter(command)
# mkdir -p /some/dir
# mkdir /some/dir
cmd_parts = command.strip.split(/\s+/)
dir = cmd_parts.pop
while !dir.nil? && dir.start_with?('-')
dir = cmd_parts.pop
end
# This will ignore any -p switches, which are redundant in PowerShell,
# and ambiguous in PowerShell 4+
return "mkdir #{dir} -force"
end
def accept?(command)
command.start_with?('mkdir ')
end
end
end
end
end