Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Don't fail on npm outdated returning 1 #8

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/poise_javascript/resources/node_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def check_package_versions(resource)
# here so you get slow behavior, sorry.
requested_packages = Set.new(Array(resource.package_name))
if npm_version?('>= 1.3.16') && version_data.any? {|pkg_name, _pkg_vers| requested_packages.include?(pkg_name) }
outdated = npm_shell_out!('outdated') || {}
outdated = npm_shell_out!('outdated', shellout_options: { returns: [0, 1] }) || {}
version_data.each do |pkg_name, pkg_vers|
pkg_vers[:candidate] = if outdated.include?(pkg_name)
outdated[pkg_name]['wanted']
Expand Down Expand Up @@ -201,7 +201,7 @@ def remove_package(name, version)
# @param args [Array<String>] Command arguments.
# @param parse_json [Boolean] Parse the JSON on stdout.
# @return [Hash]
def npm_shell_out!(subcmd, args=[], parse_json: true)
def npm_shell_out!(subcmd, args=[], parse_json: true, shellout_options: {})
cmd = [new_resource.npm_binary, subcmd, '--json']
# If path is nil, we are in global mode.
cmd << '--global' unless new_resource.path
Expand All @@ -210,7 +210,7 @@ def npm_shell_out!(subcmd, args=[], parse_json: true)
# If we are in global mode, cwd will be nil so probably just fine. Add
# the directory for the node binary to $PATH for post-install stuffs.
new_path = [::File.dirname(new_resource.javascript), ENV['PATH'].to_s].join(::File::PATH_SEPARATOR)
out = javascript_shell_out!(cmd, cwd: new_resource.path, group: new_resource.group, user: new_resource.user, environment: {'PATH' => new_path})
out = javascript_shell_out!(cmd, cwd: new_resource.path, group: new_resource.group, user: new_resource.user, environment: {'PATH' => new_path}, **shellout_options)
if parse_json
# Parse the JSON.
if out.stdout.strip.empty?
Expand Down