diff options
| author | Mike McQuaid | 2017-07-07 15:59:35 +0100 |
|---|---|---|
| committer | GitHub | 2017-07-07 15:59:35 +0100 |
| commit | 0740855f81e0ba845c412d48ff2188f4301b9f75 (patch) | |
| tree | 8a63f56a1fbf806068246ff4ff878c91b00279bb | |
| parent | 81dbc29566a85f817b5a33c98fc5868d250784cf (diff) | |
| parent | 9f6762d958ad8da9941c687ffe949f60267070cf (diff) | |
| download | brew-0740855f81e0ba845c412d48ff2188f4301b9f75.tar.bz2 | |
Merge pull request #2870 from MikeMcQuaid/node-cleanup
language/node: general cleanup.
| -rw-r--r-- | Library/Homebrew/language/node.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/test/language/node_spec.rb | 12 |
2 files changed, 4 insertions, 11 deletions
diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index eaadc54fc..ce9baea21 100644 --- a/Library/Homebrew/language/node.rb +++ b/Library/Homebrew/language/node.rb @@ -10,8 +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 --ignore-scripts" - output = Utils.popen_read(pack_cmd) + output = Utils.popen_read("npm pack --ignore-scripts") if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty? raise "npm failed to pack #{Dir.pwd}" end diff --git a/Library/Homebrew/test/language/node_spec.rb b/Library/Homebrew/test/language/node_spec.rb index 5ddbde944..fdc3871af 100644 --- a/Library/Homebrew/test/language/node_spec.rb +++ b/Library/Homebrew/test/language/node_spec.rb @@ -26,25 +26,19 @@ describe Language::Node do npm_pack_cmd = "npm pack --ignore-scripts" it "raises error with non zero exitstatus" do - 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) + allow(Utils).to receive(:popen_read).with(npm_pack_cmd) { `false` } 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(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) + allow(Utils).to receive(:popen_read).with(npm_pack_cmd) { `true` } 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_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) + allow(Utils).to receive(:popen_read).with(npm_pack_cmd) { `echo pack.tgz` } resp = subject.std_npm_install_args(npm_install_arg) expect(resp).to include("--prefix=#{npm_install_arg}", "#{Dir.pwd}/pack.tgz") end |
