Skip to content

Commit

Permalink
Read the exit code from the output status
Browse files Browse the repository at this point in the history
This is needed with Puppet 6 since $CHILD_STATUS is no longer guaranteed
to be populated.
  • Loading branch information
ekohl committed Apr 30, 2020
1 parent 74bde6b commit 1f70511
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/provider/package/npm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

def self.npmlist
# Ignore non-zero exit codes as they can be minor, just try and parse JSON
output = execute([command(:npm), 'list', '--json', '--global'], combine: false)
Puppet.debug("Warning: npm list --json exited with code #{$CHILD_STATUS.exitstatus}") unless $CHILD_STATUS.success?
output = execute([command(:npm), 'list', '--json', '--global'], combine: false, failonfail: false)
Puppet.debug("Warning: npm list --json exited with code #{output.exitstatus}") if output.exitstatus != 0
begin
# ignore any npm output lines to be a bit more robust
output = PSON.parse(output.lines.select { |l| l =~ %r{^((?!^npm).*)$} }.join("\n"), max_nesting: 100)
Expand Down

0 comments on commit 1f70511

Please sign in to comment.