From 495520a1f9d55712a6a0d3eae6123fda60dbaeae Mon Sep 17 00:00:00 2001 From: Christian Moritz Date: Mon, 26 Jun 2017 21:33:12 +0200 Subject: [PATCH] language/node: make packname detection more robust This fixes some edge cases where verbose output from a prepublish script could break our npm pack package name detection code by only using the last line of the output printed by npm itself containing the desired package name. --- Library/Homebrew/language/node.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index 98d376766b..86874e385c 100644 --- a/Library/Homebrew/language/node.rb +++ b/Library/Homebrew/language/node.rb @@ -11,8 +11,10 @@ module Language # directory, consequently breaking that assumption. We require a tarball # because npm install creates a "real" installation when fed a tarball. output = Utils.popen_read("npm pack").chomp - raise "npm failed to pack #{Dir.pwd}" unless $CHILD_STATUS.exitstatus.zero? - output + if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty? + raise "npm failed to pack #{Dir.pwd}" + end + output.lines.last.chomp end def self.setup_npm_environment