diff options
| author | Max Howell | 2013-07-16 14:46:02 -0500 |
|---|---|---|
| committer | Max Howell | 2013-07-17 10:07:55 -0500 |
| commit | f88d5b8559992ee9641a06beaf420b1e2c6b2976 (patch) | |
| tree | ca6925f55b21f362e608b3e13671f52f1e6a487a /Library/Formula | |
| parent | e9b95c57f92bf07f917d1be4f702d3a245bc085d (diff) | |
| download | homebrew-f88d5b8559992ee9641a06beaf420b1e2c6b2976.tar.bz2 | |
Make the global npm prefix: HOMEBREW_PREFIX
This works well, HOMEBREW_PREFIX/lib/node_modules is where node modules are installed. Manpages are now accessible. Binaries are symlinks in HOMEBREW_PREFIX/bin.
Because before this patch node modules installed to /share/node, we check for that and if it exists, we set that as the prefix instead.
Diffstat (limited to 'Library/Formula')
| -rw-r--r-- | Library/Formula/node.rb | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/Library/Formula/node.rb b/Library/Formula/node.rb index 87656efa0..f1677aa19 100644 --- a/Library/Formula/node.rb +++ b/Library/Formula/node.rb @@ -65,39 +65,31 @@ class Node < Formula unless build.include? 'without-npm' (lib/"node_modules/npm/npmrc").write("prefix = #{npm_prefix}\n") + # we need to force make this directory, or node modules installed here + # by npm will end up in the node keg and won't survive upgrades + mkdir_p "#{HOMEBREW_PREFIX}/lib/node_modules" end end def npm_prefix - "#{HOMEBREW_PREFIX}/share/npm" - end - - def npm_bin - "#{npm_prefix}/bin" - end - - def modules_folder - "#{HOMEBREW_PREFIX}/lib/node_modules" + d = "#{HOMEBREW_PREFIX}/share/npm" + if File.directory? d + d + else + HOMEBREW_PREFIX.to_s + end end def caveats - if build.include? 'without-npm' - <<-EOS.undent - Homebrew has NOT installed npm. We recommend the following method of - installation: - curl https://npmjs.org/install.sh | sh - - After installing, add the following path to your NODE_PATH environment - variable to have npm libraries picked up: - #{modules_folder} - EOS - elsif not ENV['PATH'].split(':').include? npm_bin - <<-EOS.undent - Homebrew installed npm. - We recommend prepending the following path to your PATH environment - variable to have npm-installed binaries picked up: - #{npm_bin} - EOS + if build.include? 'without-npm' then <<-end.undent + Homebrew has NOT installed npm. If you later install it, you should supplement + your NODE_PATH with the npm module folder: + #{npm_prefix}/lib/node_modules + end + elsif not ENV['PATH'].split(':').include? "#{npm_prefix}/bin"; <<-end.undent + Probably you should amend your PATH to include npm-installed binaries: + #{npm_prefix}/bin + end end end end |
