module VagrantPlugins
  module ProxyConf
    module Cap
      module Linux
        # Capability for npm proxy configuration
        module NpmProxyConf
          # @return [Boolean] if npm is installed
          def self.npm_proxy_conf(machine)
            machine.communicate.test('which npm')
          end
        end
      end
    end
  end
end

module VagrantPlugins
  module ProxyConf
    module Cap
      module Linux
        # Capability for npm proxy configuration
        module NpmProxyConf
          # @return [Boolean] if npm is installed
          def self.npm_proxy_conf(machine)
            machine.communicate.test('which npm', sudo: true)
          end
        end
      end
    end
  end
end

Test for npm availability in sudo context
Test for npm availability in sudo context

npm proxy provider runs
@machine.communicate.sudo(command).

cap provider verifies availability of npm with `which' NOT
using sudo.

This may result in:
- which succeeds for the ssh user (mostly vagrant)
- machine.communicate.sudo('npm do something') does not
  succeed because sudo target user does not have the same
  PATH variable configured.

This may result in the following error message breaking the
Vagrant environment completely:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

npm config set proxy http://some.configured.proxy.here:8080/

Stdout from the command:

Stderr from the command:

bash: line 2: npm: command not found
