From 7d8124f339aeffb7b444f460b581d13668f953c3 Mon Sep 17 00:00:00 2001 From: Christian Moritz Date: Mon, 26 Jun 2017 20:28:18 +0200 Subject: language/node: set npm loglevel to max -ddd to match the loglevel used in npm_debug.log (previous --verbose loglevel would match -dd) --- Library/Homebrew/language/node.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/language/node.rb') diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index 01d41041b..6aaeacbea 100644 --- a/Library/Homebrew/language/node.rb +++ b/Library/Homebrew/language/node.rb @@ -42,7 +42,7 @@ module Language # npm install args for global style module format installed into libexec %W[ - --verbose + -ddd --global --prefix=#{libexec} #{Dir.pwd}/#{pack} @@ -52,7 +52,7 @@ module Language def self.local_npm_install_args setup_npm_environment # npm install args for local style module format - ["--verbose"] + ["-ddd"] end end end -- cgit v1.2.3 From 02113e2714aae818ee2c43e203137b3cd0b61ced Mon Sep 17 00:00:00 2001 From: Christian Moritz Date: Mon, 26 Jun 2017 20:35:48 +0200 Subject: language/node: build native addons from source By telling node-pre-gyp and prebuild to don't pull prebuild binaries and instead build them from source. This still may not work for some custom third party scripts for pulling prebuild binaries. --- Library/Homebrew/language/node.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/language/node.rb') diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index 6aaeacbea..98d376766 100644 --- a/Library/Homebrew/language/node.rb +++ b/Library/Homebrew/language/node.rb @@ -44,6 +44,7 @@ module Language %W[ -ddd --global + --build-from-source --prefix=#{libexec} #{Dir.pwd}/#{pack} ] @@ -52,7 +53,10 @@ module Language def self.local_npm_install_args setup_npm_environment # npm install args for local style module format - ["-ddd"] + %w[ + -ddd + --build-from-source + ] end end end -- cgit v1.2.3 From 495520a1f9d55712a6a0d3eae6123fda60dbaeae Mon Sep 17 00:00:00 2001 From: Christian Moritz Date: Mon, 26 Jun 2017 21:33:12 +0200 Subject: 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(-) (limited to 'Library/Homebrew/language/node.rb') diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index 98d376766..86874e385 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 -- cgit v1.2.3 From fe39dbb78c2d62111358bfa00b6219ef43db7a4f Mon Sep 17 00:00:00 2001 From: Christian Moritz Date: Mon, 26 Jun 2017 21:34:05 +0200 Subject: language/node: log verbose npm pack output This makes npm pack to log verbose debug output to the console to simplify debugging npm pack failures. Refs: https://github.com/Homebrew/brew/pull/2820#discussion_r123890729 Prevously Utils.popen_read swallowed all debug output. --- Library/Homebrew/language/node.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/language/node.rb') diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index 86874e385..02885d62f 100644 --- a/Library/Homebrew/language/node.rb +++ b/Library/Homebrew/language/node.rb @@ -10,7 +10,9 @@ module Language # fed to `npm install` only symlinks are created linking back to that # 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 + pack_cmd = "npm pack -ddd" + ohai pack_cmd + output = `#{pack_cmd}` if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty? raise "npm failed to pack #{Dir.pwd}" end -- cgit v1.2.3 From 466fe9841a9af915fe78c1fd8648a745610f942d Mon Sep 17 00:00:00 2001 From: Christian Moritz Date: Thu, 29 Jun 2017 20:24:15 +0200 Subject: language/node: npm pack ignore prepublish scripts This tells npm pack to don't run prepublish scripts at all. I think this is the best default because: * most modules don't have a prepublish script at all and aren't affected by this change * most prepublish scripts are calling devDeps, which would fail in our case, because (dev)Deps aren't installed at npm pack time until #2820 gets resolved * we favor npm registry tarball for formula downloads, which are already prepublished, so we would in the best case needlessly run prepublish a second time and in the worst case it would fail (because a clean step is required before running prepublish a second time in a row) * This change does the right thing for >99% of all the packages and would only affect packages with prepublish scripts downloaded from a non-npm registry tarball (like github tarballs) and with a prepublish script wich does no't require any devDep (unlike for cross platform) --- Library/Homebrew/language/node.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/language/node.rb') diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index 02885d62f..03fa9e522 100644 --- a/Library/Homebrew/language/node.rb +++ b/Library/Homebrew/language/node.rb @@ -10,7 +10,7 @@ module Language # fed to `npm install` only symlinks are created linking back to that # directory, consequently breaking that assumption. We require a tarball # because npm install creates a "real" installation when fed a tarball. - pack_cmd = "npm pack -ddd" + pack_cmd = "npm pack -ddd --ignore-scripts" ohai pack_cmd output = `#{pack_cmd}` if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty? -- cgit v1.2.3 From 6baea2543aef21d996f04a3eff96185c4a6feba1 Mon Sep 17 00:00:00 2001 From: Christian Moritz Date: Mon, 26 Jun 2017 21:47:47 +0200 Subject: language/node: set cache config via argument instead of writing a .npmrc file, which simplifies the code. npm_cache_config is still preserved for backwarts compatiblility and usage int he kibana@n formulas in core. --- Library/Homebrew/language/node.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'Library/Homebrew/language/node.rb') diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index 03fa9e522..0d02a2ad0 100644 --- a/Library/Homebrew/language/node.rb +++ b/Library/Homebrew/language/node.rb @@ -1,7 +1,7 @@ module Language module Node def self.npm_cache_config - "cache=#{HOMEBREW_CACHE}/npm_cache\n" + "cache=#{HOMEBREW_CACHE}/npm_cache" end def self.pack_for_installation @@ -20,13 +20,9 @@ module Language end def self.setup_npm_environment - npmrc = Pathname.new("#{ENV["HOME"]}/.npmrc") - # only run setup_npm_environment once per formula - return if npmrc.exist? - # explicitly set npm's cache path to HOMEBREW_CACHE/npm_cache to fix - # issues caused by overriding $HOME (long build times, high disk usage) - # https://github.com/Homebrew/brew/pull/37#issuecomment-208840366 - npmrc.write npm_cache_config + # guard that this is only run once + return if @env_set + @env_set = true # explicitly use our npm and node-gyp executables instead of the user # managed ones in HOMEBREW_PREFIX/lib/node_modules which might be broken begin @@ -49,6 +45,7 @@ module Language -ddd --global --build-from-source + --#{npm_cache_config} --prefix=#{libexec} #{Dir.pwd}/#{pack} ] @@ -57,9 +54,10 @@ module Language def self.local_npm_install_args setup_npm_environment # npm install args for local style module format - %w[ + %W[ -ddd --build-from-source + --#{npm_cache_config} ] end end -- cgit v1.2.3 From 5e00c277ce45d6af497ec135faf54571c340e704 Mon Sep 17 00:00:00 2001 From: Christian Moritz Date: Thu, 29 Jun 2017 20:49:29 +0200 Subject: partly revert log verbose npm pack output commit to fix issues with shwoing npm debug output even on non-verbose install runs. --- Library/Homebrew/language/node.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/language/node.rb') diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index 0d02a2ad0..eaadc54fc 100644 --- a/Library/Homebrew/language/node.rb +++ b/Library/Homebrew/language/node.rb @@ -10,9 +10,8 @@ module Language # fed to `npm install` only symlinks are created linking back to that # directory, consequently breaking that assumption. We require a tarball # because npm install creates a "real" installation when fed a tarball. - pack_cmd = "npm pack -ddd --ignore-scripts" - ohai pack_cmd - output = `#{pack_cmd}` + pack_cmd = "npm pack --ignore-scripts" + output = Utils.popen_read(pack_cmd) if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty? raise "npm failed to pack #{Dir.pwd}" end -- cgit v1.2.3