aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/node.rb68
1 files changed, 40 insertions, 28 deletions
diff --git a/Library/Formula/node.rb b/Library/Formula/node.rb
index 3a784fdbe..c8f3b14b4 100644
--- a/Library/Formula/node.rb
+++ b/Library/Formula/node.rb
@@ -3,7 +3,7 @@ class Node < Formula
homepage "https://nodejs.org/"
url "https://nodejs.org/dist/v0.10.35/node-v0.10.35.tar.gz"
sha256 "0043656bb1724cb09dbdc960a2fd6ee37d3badb2f9c75562b2d11235daa40a03"
- revision 1
+ revision 2
bottle do
sha1 "652168b4eed7141cdd648e9463dc246a6b7f2e60" => :yosemite
@@ -36,8 +36,8 @@ class Node < Formula
end
resource "npm" do
- url "https://registry.npmjs.org/npm/-/npm-2.1.17.tgz"
- sha1 "80fa7873188659037ec0ed8ebc95c2b2723c8ac4"
+ url "https://registry.npmjs.org/npm/-/npm-2.1.18.tgz"
+ sha1 "e2af4c5f848fb023851cd2ec129005d33090bd57"
end
def install
@@ -55,42 +55,54 @@ class Node < Formula
system "./configure", *args
system "make", "install"
- resource("npm").stage libexec/"npm" if build.with? "npm"
- end
+ if build.with? "npm"
+ resource("npm").stage buildpath/"npm_install"
- def post_install
- return if build.without? "npm"
+ # make sure npm can find node
+ ENV.prepend_path "PATH", bin
- (libexec/"npm").cd { system "make", "uninstall" }
- Pathname.glob(HOMEBREW_PREFIX/"share/man/*") do |man|
- next unless man.directory?
- man.children.each do |file|
- next unless file.symlink?
- file.unlink if file.readlink.to_s.include? "/node_modules/npm/man/"
+ # set log level temporarily for npm's `make install`
+ ENV["NPM_CONFIG_LOGLEVEL"] = "verbose"
+
+ cd buildpath/"npm_install" do
+ system "./configure", "--prefix=#{libexec}/npm"
+ system "make", "install"
+ end
+
+ if build.with? "completion"
+ bash_completion.install \
+ buildpath/"npm_install/lib/utils/completion.sh" => "npm"
end
end
+ end
+
+ def post_install
+ return if build.without? "npm"
node_modules = HOMEBREW_PREFIX/"lib/node_modules"
node_modules.mkpath
- cp_r libexec/"npm", node_modules
+ npm_exec = node_modules/"npm/bin/npm-cli.js"
+ # Kill npm but preserve all other modules across node updates/upgrades.
+ rm_rf node_modules/"npm"
+
+ cp_r libexec/"npm/lib/node_modules/npm", node_modules
+ # This symlink doesn't hop into homebrew_prefix/bin automatically so
+ # remove it and make our own. This is a small consequence of our bottle
+ # npm make install workaround. All other installs **do** symlink to
+ # homebrew_prefix/bin correctly. We ln rather than cp this because doing
+ # so mimics npm's normal install.
+ ln_sf npm_exec, "#{HOMEBREW_PREFIX}/bin/npm"
+
+ # Let's do the manpage dance. It's just a jump to the left.
+ # And then a step to the right, with your hand on rm_f.
+ ["man1", "man3", "man5", "man7"].each do |man|
+ rm_f Dir[HOMEBREW_PREFIX/"share/man/#{man}/{npm.,npm-,npmrc.}*"]
+ Dir[share/"man/#{man}/npm*"].each {|f| ln_sf f, HOMEBREW_PREFIX/"share/man/#{man}" }
+ end
npm_root = node_modules/"npm"
npmrc = npm_root/"npmrc"
npmrc.atomic_write("prefix = #{HOMEBREW_PREFIX}\n")
-
- # set log level temporarily for npm's `make install`
- ENV["NPM_CONFIG_LOGLEVEL"] = "verbose"
-
- # make sure npm can find node
- ENV["PATH"] = "#{opt_bin}:#{ENV["PATH"]}"
-
- ENV["NPM_CONFIG_USERCONFIG"] = npmrc
- npm_root.cd { system "make", "install" }
-
- if build.with? "completion"
- bash_completion.install_symlink \
- npm_root/"lib/utils/completion.sh" => "npm"
- end
end
def caveats