Sha256: 7e0b1b6cef32d325a84e845ea7647cdec8de9e0f2d563297904b0c215872df3f

Contents?: true

Size: 732 Bytes

Versions: 1

Compression:

Stored size: 732 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-cloudstack-1.2.0 vendor/bundle/bundler/gems/vagrant-c84e05fd063f/plugins/communicators/winrm/command_filters/mkdir.rb