Sha256: 2e35e16d38573136795cb32e91168e75b889e5f2f4d23706cce83c52a46e1012
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
module VagrantWindows module Communication module CommandFilters # Converts a *nix 'test' command to a PowerShell equivalent class Test def filter(command) # test -d /tmp/dir # test -f /tmp/afile # test -L /somelink # test -x /tmp/some.exe cmd_parts = command.strip.split(/\s+/) if cmd_parts[1] == '-d' # ensure it exists and is a directory return "if ((Test-Path '#{cmd_parts[2]}') -and (get-item '#{cmd_parts[2]}').PSIsContainer) { exit 0 } exit 1" elsif cmd_parts[1] == '-f' || cmd_parts[1] == '-x' # ensure it exists and is a file return "if ((Test-Path '#{cmd_parts[2]}') -and (!(get-item '#{cmd_parts[2]}').PSIsContainer)) { exit 0 } exit 1" end # otherwise, just check for existence return "if (Test-Path '#{cmd_parts[2]}') { exit 0 } exit 1" end # if (Test-Path 'c:\windows' && (get-item 'c:\windows').PSIsContainer) { Write-Host 0 } Write-Host 1 def accept?(command) command.start_with?('test ') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-windows-1.7.0.pre.2 | lib/vagrant-windows/communication/command_filters/test.rb |
vagrant-windows-1.7.0.pre.1 | lib/vagrant-windows/communication/command_filters/test.rb |