2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-10-10 23:16:57 +00:00
|
|
|
|
2012-09-04 05:21:40 +00:00
|
|
|
class PythonVersion < Requirement
|
|
|
|
def message; <<-EOS.undent
|
|
|
|
Node's build system, gyp, requires Python 2.6 or newer.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
def satisfied?
|
|
|
|
`python -c 'import sys;print(sys.version[:3])'`.strip.to_f >= 2.6
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-27 03:38:24 +00:00
|
|
|
class NpmNotInstalled < Requirement
|
|
|
|
def modules_folder
|
|
|
|
"#{HOMEBREW_PREFIX}/lib/node_modules"
|
|
|
|
end
|
|
|
|
|
|
|
|
def message; <<-EOS.undent
|
|
|
|
The homebrew node recipe now (beginning with 0.8.0) comes with npm.
|
|
|
|
It appears you already have npm installed at #{modules_folder}/npm.
|
|
|
|
To use the npm that comes with this recipe,
|
|
|
|
first uninstall npm with `npm uninstall npm -g`.
|
|
|
|
Then run this command again.
|
|
|
|
|
|
|
|
If you would like to keep your installation of npm instead of
|
|
|
|
using the one provided with homebrew,
|
|
|
|
install the formula with the --without-npm option added.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def satisfied?
|
|
|
|
begin
|
|
|
|
path = Pathname.new("#{modules_folder}/npm")
|
|
|
|
not path.realpath.to_s.include?(HOMEBREW_CELLAR)
|
|
|
|
rescue Exception => e
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def fatal?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Node < Formula
|
2012-01-26 05:00:23 +00:00
|
|
|
homepage 'http://nodejs.org/'
|
2012-12-14 05:40:04 +00:00
|
|
|
url 'http://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz'
|
|
|
|
sha1 '6479366bfbc2b4392f7f496dec55b5ab719308c0'
|
2012-12-29 04:50:32 +00:00
|
|
|
devel do
|
2012-12-30 01:46:24 +00:00
|
|
|
url 'http://nodejs.org/dist/v0.9.5/node-v0.9.5.tar.gz'
|
|
|
|
sha1 'a1f1322fcaa5535ae830f3242bcdd213388357cc'
|
2012-12-29 04:50:32 +00:00
|
|
|
end
|
2012-02-18 01:10:45 +00:00
|
|
|
|
2012-01-26 05:00:23 +00:00
|
|
|
head 'https://github.com/joyent/node.git'
|
|
|
|
|
2011-06-01 16:21:03 +00:00
|
|
|
# Leopard OpenSSL is not new enough, so use our keg-only one
|
2012-09-05 04:04:01 +00:00
|
|
|
depends_on 'openssl' if MacOS.version == :leopard
|
2012-06-27 03:38:24 +00:00
|
|
|
depends_on NpmNotInstalled.new unless build.include? 'without-npm'
|
2012-09-04 05:21:40 +00:00
|
|
|
depends_on PythonVersion.new
|
2011-06-01 16:21:03 +00:00
|
|
|
|
2012-08-13 00:03:04 +00:00
|
|
|
option 'enable-debug', 'Build with debugger hooks'
|
2012-06-27 03:38:24 +00:00
|
|
|
option 'without-npm', 'npm will not be installed'
|
2012-08-13 00:03:04 +00:00
|
|
|
|
2012-03-18 20:33:24 +00:00
|
|
|
fails_with :llvm do
|
|
|
|
build 2326
|
|
|
|
end
|
2011-03-21 21:24:22 +00:00
|
|
|
|
2009-10-10 23:16:57 +00:00
|
|
|
def install
|
2012-09-14 00:24:45 +00:00
|
|
|
# Lie to `xcode-select` for now to work around a GYP bug that affects
|
|
|
|
# CLT-only systems:
|
|
|
|
#
|
|
|
|
# http://code.google.com/p/gyp/issues/detail?id=292
|
|
|
|
# joyent/node#3681
|
2012-09-14 01:54:17 +00:00
|
|
|
ENV['DEVELOPER_DIR'] = MacOS.dev_tools_path unless MacOS::Xcode.installed?
|
2012-09-14 00:24:45 +00:00
|
|
|
|
2012-06-27 03:38:24 +00:00
|
|
|
args = %W{--prefix=#{prefix}}
|
2012-08-13 00:03:04 +00:00
|
|
|
args << "--debug" if build.include? 'enable-debug'
|
2012-06-27 03:38:24 +00:00
|
|
|
args << "--without-npm" if build.include? 'without-npm'
|
2010-08-09 05:08:08 +00:00
|
|
|
|
|
|
|
system "./configure", *args
|
2009-10-10 23:16:57 +00:00
|
|
|
system "make install"
|
2012-06-27 03:38:24 +00:00
|
|
|
|
2012-08-28 04:55:39 +00:00
|
|
|
unless build.include? 'without-npm'
|
2012-06-27 03:38:24 +00:00
|
|
|
(lib/"node_modules/npm/npmrc").write(npmrc)
|
|
|
|
end
|
2009-10-10 23:16:57 +00:00
|
|
|
end
|
2010-12-28 11:11:21 +00:00
|
|
|
|
2012-06-27 03:38:24 +00:00
|
|
|
def npm_prefix
|
|
|
|
"#{HOMEBREW_PREFIX}/share/npm"
|
|
|
|
end
|
|
|
|
|
|
|
|
def npm_bin
|
|
|
|
"#{npm_prefix}/bin"
|
|
|
|
end
|
|
|
|
|
|
|
|
def modules_folder
|
|
|
|
"#{HOMEBREW_PREFIX}/lib/node_modules"
|
|
|
|
end
|
2011-12-02 03:19:47 +00:00
|
|
|
|
2012-06-27 03:38:24 +00:00
|
|
|
def npmrc
|
|
|
|
<<-EOS.undent
|
|
|
|
prefix = #{npm_prefix}
|
2011-12-02 03:19:47 +00:00
|
|
|
EOS
|
2010-12-28 11:11:21 +00:00
|
|
|
end
|
2012-06-27 03:38:24 +00:00
|
|
|
|
|
|
|
def caveats
|
2012-08-28 04:55:39 +00:00
|
|
|
if build.include? 'without-npm'
|
2012-06-27 03:38:24 +00:00
|
|
|
<<-EOS.undent
|
|
|
|
Homebrew has NOT installed npm. We recommend the following method of
|
|
|
|
installation:
|
2012-08-30 09:48:07 +00:00
|
|
|
curl https://npmjs.org/install.sh | sh
|
2012-06-27 03:38:24 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|
2009-10-10 23:16:57 +00:00
|
|
|
end
|