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/test/language/node_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/language/node_spec.rb b/Library/Homebrew/test/language/node_spec.rb index b2114bc4f..4116c8581 100644 --- a/Library/Homebrew/test/language/node_spec.rb +++ b/Library/Homebrew/test/language/node_spec.rb @@ -41,6 +41,6 @@ describe Language::Node do specify "#local_npm_install_args" do resp = subject.local_npm_install_args - expect(resp).to include("--verbose") + expect(resp).to include("-ddd") 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/test/language/node_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/language/node_spec.rb b/Library/Homebrew/test/language/node_spec.rb index 4116c8581..55bb1574e 100644 --- a/Library/Homebrew/test/language/node_spec.rb +++ b/Library/Homebrew/test/language/node_spec.rb @@ -41,6 +41,6 @@ describe Language::Node do specify "#local_npm_install_args" do resp = subject.local_npm_install_args - expect(resp).to include("-ddd") + expect(resp).to include("-ddd", "--build-from-source") end end -- 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/test/language/node_spec.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/language/node_spec.rb b/Library/Homebrew/test/language/node_spec.rb index 55bb1574e..b822c2350 100644 --- a/Library/Homebrew/test/language/node_spec.rb +++ b/Library/Homebrew/test/language/node_spec.rb @@ -24,18 +24,28 @@ describe Language::Node do describe "#std_npm_install_args" do npm_install_arg = "libexec" + npm_pack_cmd = "npm pack -ddd" it "raises error with non zero exitstatus" do + allow(Language::Node).to receive(:`).with(npm_pack_cmd).and_return("error msg") + allow_any_instance_of(Process::Status).to receive(:exitstatus).and_return(42) + allow_any_instance_of(nil::NilClass).to receive(:exitstatus).and_return(42) + expect { subject.std_npm_install_args(npm_install_arg) }.to \ + raise_error("npm failed to pack #{Dir.pwd}") + end + + it "raises error with empty npm pack output" do + allow(Language::Node).to receive(:`).with(npm_pack_cmd).and_return("") expect { subject.std_npm_install_args(npm_install_arg) }.to \ raise_error("npm failed to pack #{Dir.pwd}") end it "does not raise error with a zero exitstatus" do - allow(Utils).to receive(:popen_read).with("npm pack").and_return("pack") + allow(Language::Node).to receive(:`).with(npm_pack_cmd).and_return("pack.tgz") allow_any_instance_of(Process::Status).to receive(:exitstatus).and_return(0) allow_any_instance_of(nil::NilClass).to receive(:exitstatus).and_return(0) resp = subject.std_npm_install_args(npm_install_arg) - expect(resp).to include("--prefix=#{npm_install_arg}", "#{Dir.pwd}/pack") + expect(resp).to include("--prefix=#{npm_install_arg}", "#{Dir.pwd}/pack.tgz") end 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/test/language/node_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/language/node_spec.rb b/Library/Homebrew/test/language/node_spec.rb index b822c2350..e4ed9ee1f 100644 --- a/Library/Homebrew/test/language/node_spec.rb +++ b/Library/Homebrew/test/language/node_spec.rb @@ -24,7 +24,7 @@ describe Language::Node do describe "#std_npm_install_args" do npm_install_arg = "libexec" - npm_pack_cmd = "npm pack -ddd" + npm_pack_cmd = "npm pack -ddd --ignore-scripts" it "raises error with non zero exitstatus" do allow(Language::Node).to receive(:`).with(npm_pack_cmd).and_return("error msg") -- 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/test/language/node_spec.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/language/node_spec.rb b/Library/Homebrew/test/language/node_spec.rb index e4ed9ee1f..a8f95fe9a 100644 --- a/Library/Homebrew/test/language/node_spec.rb +++ b/Library/Homebrew/test/language/node_spec.rb @@ -2,22 +2,21 @@ require "language/node" describe Language::Node do describe "#setup_npm_environment" do - it "does nothing when npmrc exists" do - expect(subject.setup_npm_environment).to be_nil - end - - it "calls prepend_path when node formula exists and npmrc does not exist" do + it "calls prepend_path when node formula exists only during the first call" do node = formula "node" do url "node-test" end stub_formula_loader(node) - allow_any_instance_of(Pathname).to receive(:exist?).and_return(false) expect(ENV).to receive(:prepend_path) - subject.setup_npm_environment + subject.instance_variable_set(:@env_set, false) + expect(subject.setup_npm_environment).to be_nil + + expect(subject.instance_variable_get(:@env_set)).to eq(true) + expect(ENV).not_to receive(:prepend_path) + expect(subject.setup_npm_environment).to be_nil end - it "does not call prepend_path when node formula does not exist but npmrc exists" do - allow_any_instance_of(Pathname).to receive(:exist?).and_return(false) + it "does not call prepend_path when node formula does not exist" do expect(subject.setup_npm_environment).to be_nil end end @@ -51,6 +50,6 @@ describe Language::Node do specify "#local_npm_install_args" do resp = subject.local_npm_install_args - expect(resp).to include("-ddd", "--build-from-source") + expect(resp).to include("-ddd", "--build-from-source", "--cache=#{HOMEBREW_CACHE}/npm_cache") 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/test/language/node_spec.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/language/node_spec.rb b/Library/Homebrew/test/language/node_spec.rb index a8f95fe9a..5ddbde944 100644 --- a/Library/Homebrew/test/language/node_spec.rb +++ b/Library/Homebrew/test/language/node_spec.rb @@ -23,10 +23,10 @@ describe Language::Node do describe "#std_npm_install_args" do npm_install_arg = "libexec" - npm_pack_cmd = "npm pack -ddd --ignore-scripts" + npm_pack_cmd = "npm pack --ignore-scripts" it "raises error with non zero exitstatus" do - allow(Language::Node).to receive(:`).with(npm_pack_cmd).and_return("error msg") + allow(Utils).to receive(:popen_read).with(npm_pack_cmd).and_return("error msg") allow_any_instance_of(Process::Status).to receive(:exitstatus).and_return(42) allow_any_instance_of(nil::NilClass).to receive(:exitstatus).and_return(42) expect { subject.std_npm_install_args(npm_install_arg) }.to \ @@ -34,13 +34,15 @@ describe Language::Node do end it "raises error with empty npm pack output" do - allow(Language::Node).to receive(:`).with(npm_pack_cmd).and_return("") + allow(Utils).to receive(:popen_read).with(npm_pack_cmd).and_return("") + allow_any_instance_of(Process::Status).to receive(:exitstatus).and_return(0) + allow_any_instance_of(nil::NilClass).to receive(:exitstatus).and_return(0) expect { subject.std_npm_install_args(npm_install_arg) }.to \ raise_error("npm failed to pack #{Dir.pwd}") end it "does not raise error with a zero exitstatus" do - allow(Language::Node).to receive(:`).with(npm_pack_cmd).and_return("pack.tgz") + allow(Utils).to receive(:popen_read).with(npm_pack_cmd).and_return("pack.tgz") allow_any_instance_of(Process::Status).to receive(:exitstatus).and_return(0) allow_any_instance_of(nil::NilClass).to receive(:exitstatus).and_return(0) resp = subject.std_npm_install_args(npm_install_arg) -- cgit v1.2.3