2010-05-25 18:46:33 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class Npm <Formula
|
2010-11-14 19:24:57 +00:00
|
|
|
url 'https://github.com/isaacs/npm/tarball/v0.2.7-3'
|
|
|
|
homepage 'http://npmjs.org/'
|
|
|
|
md5 '97968c39b50e041ba52ddedb4bc0ee09'
|
2010-07-22 02:44:55 +00:00
|
|
|
head 'git://github.com/isaacs/npm.git'
|
2010-05-25 18:46:33 +00:00
|
|
|
|
|
|
|
depends_on 'node'
|
|
|
|
|
2010-09-23 12:58:01 +00:00
|
|
|
skip_clean 'share/npm/bin'
|
|
|
|
|
2010-08-08 04:35:47 +00:00
|
|
|
def executable; <<-EOS
|
2010-06-07 22:59:12 +00:00
|
|
|
#!/bin/sh
|
|
|
|
exec "#{libexec}/cli.js" "$@"
|
2010-08-08 04:35:47 +00:00
|
|
|
EOS
|
2010-06-07 22:59:12 +00:00
|
|
|
end
|
|
|
|
|
2010-07-22 03:00:34 +00:00
|
|
|
def node_lib
|
2010-09-29 11:11:26 +00:00
|
|
|
HOMEBREW_PREFIX+"lib/node"
|
2010-07-22 03:00:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def share_bin
|
2010-09-29 11:11:26 +00:00
|
|
|
HOMEBREW_PREFIX+"share/npm/bin"
|
2010-07-22 03:00:34 +00:00
|
|
|
end
|
|
|
|
|
2010-05-25 18:46:33 +00:00
|
|
|
def install
|
2010-07-22 03:00:34 +00:00
|
|
|
# Set a root & binroot that won't get wiped between updates
|
|
|
|
share_bin.mkpath
|
|
|
|
inreplace 'lib/utils/default-config.js' do |s|
|
|
|
|
s.gsub! /, binroot.*$/, ", binroot : \"#{share_bin}\""
|
|
|
|
s.gsub! /, root.*$/, ", root : \"#{node_lib}\""
|
|
|
|
end
|
|
|
|
|
2010-06-07 22:59:12 +00:00
|
|
|
prefix.install ["LICENSE", "README.md"]
|
2010-07-22 03:00:34 +00:00
|
|
|
doc.install Dir["doc/*"]
|
2010-05-25 18:46:33 +00:00
|
|
|
|
2010-06-07 22:59:12 +00:00
|
|
|
# install all the required libs in libexec so `npm help` will work
|
|
|
|
libexec.install Dir["*"]
|
|
|
|
|
|
|
|
# add "npm-" prefix to man pages link them into the libexec man pages
|
2010-05-25 18:46:33 +00:00
|
|
|
man1.mkpath
|
2010-09-23 12:58:01 +00:00
|
|
|
Dir.chdir libexec + "man1" do
|
2010-06-07 22:59:12 +00:00
|
|
|
Dir["*"].each do |file|
|
|
|
|
if file == "npm.1"
|
2010-09-23 12:58:01 +00:00
|
|
|
ln_s "#{Dir.pwd}/#{file}", man1
|
2010-06-07 22:59:12 +00:00
|
|
|
else
|
2010-09-23 12:58:01 +00:00
|
|
|
ln_s "#{Dir.pwd}/#{file}", "#{man1}/npm-#{file}"
|
2010-06-07 22:59:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-05-25 18:46:33 +00:00
|
|
|
|
|
|
|
# install the wrapper executable
|
|
|
|
(bin+"npm").write executable
|
2010-11-07 21:24:17 +00:00
|
|
|
|
|
|
|
# bash-completion
|
|
|
|
(prefix+'etc/bash_completion.d').install libexec+'npm-completion.sh'
|
2010-05-25 18:46:33 +00:00
|
|
|
end
|
2010-07-22 03:00:34 +00:00
|
|
|
|
2010-08-08 04:35:47 +00:00
|
|
|
def caveats; <<-EOS.undent
|
2010-07-22 03:00:34 +00:00
|
|
|
npm will install binaries to:
|
|
|
|
#{share_bin}
|
2010-08-25 00:41:45 +00:00
|
|
|
|
2010-07-22 03:00:34 +00:00
|
|
|
You may want to add this to your PATH.
|
|
|
|
|
|
|
|
npm will install libraries to:
|
2010-08-25 00:41:45 +00:00
|
|
|
#{node_lib}/.npm
|
2010-07-22 03:00:34 +00:00
|
|
|
|
|
|
|
To manually remove libraries installed by npm, delete this (hidden!) folder.
|
2010-08-25 00:41:45 +00:00
|
|
|
|
|
|
|
npm will also symlink libraries to:
|
|
|
|
#{node_lib}
|
|
|
|
|
|
|
|
You will want to add this to your NODE_PATH if you wish to
|
|
|
|
require libraries without a path.
|
2010-07-22 03:00:34 +00:00
|
|
|
EOS
|
|
|
|
end
|
2010-05-25 18:46:33 +00:00
|
|
|
end
|