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.
This commit is contained in:
Christian Moritz 2017-06-26 21:33:12 +02:00
parent 02113e2714
commit 495520a1f9

View File

@ -11,8 +11,10 @@ module Language
# directory, consequently breaking that assumption. We require a tarball # directory, consequently breaking that assumption. We require a tarball
# because npm install creates a "real" installation when fed a tarball. # because npm install creates a "real" installation when fed a tarball.
output = Utils.popen_read("npm pack").chomp output = Utils.popen_read("npm pack").chomp
raise "npm failed to pack #{Dir.pwd}" unless $CHILD_STATUS.exitstatus.zero? if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty?
output raise "npm failed to pack #{Dir.pwd}"
end
output.lines.last.chomp
end end
def self.setup_npm_environment def self.setup_npm_environment