Skip to content

Commit

Permalink
Prevent provider blowing up on ruby 1.8 agents
Browse files Browse the repository at this point in the history
To be clear, this is not about restoring ruby 1.8 support.  This module
is now puppet 4 only and will not be able to be used on ruby 1.8
systems.

However, some puppet environments contain a mix of puppet 4 (supported)
and older puppet 3 EL6 agents. We don't want unrelated puppet runs to
fail on those old systems just because this module is in the same
environment.
  • Loading branch information
alexjfisher committed Mar 2, 2017
1 parent 1c676d7 commit 88ef7c4
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/puppet/provider/package/npm.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
require 'puppet/provider/package'

Puppet::Type.type(:package).provide :npm, parent: Puppet::Provider::Package do
Puppet::Type.type(:package).provide :npm, :parent => Puppet::Provider::Package do # rubocop:disable Style/HashSyntax
desc 'npm is the package manager for Node.js. This provider only handles global packages.'

confine feature: :npm
# We don't support using this module on puppet 3/ruby 1.8 systems.
# However, some puppet environments contain a mix of puppet 4 (supported) and older puppet 3 EL6 agents.
# We don't want puppet runs to fail on those old systems just because this module is in the same environment.
# rubocop:disable Style/HashSyntax
confine :false => %r{^1\.8}.match(RUBY_VERSION)
confine :feature => :npm

has_feature :versionable, :install_options

if Puppet::Util::Package.versioncmp(Puppet.version, '3.0') >= 0
has_command(:npm, 'npm') do
is_optional
environment HOME: '/root'
end
else
optional_commands npm: 'npm'
has_command(:npm, 'npm') do
is_optional
environment :HOME => '/root'
end
# rubocop:enable Style/HashSyntax

def self.npmlist
# Ignore non-zero exit codes as they can be minor, just try and parse JSON
Expand Down

0 comments on commit 88ef7c4

Please sign in to comment.