Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 78df17c

Browse files
committed
add iojs
1 parent 158c66d commit 78df17c

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

Library/Formula/iojs.rb

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Note that x.even are stable releases, x.odd are devel releases
2+
class Node < Formula
3+
homepage "https://iojs.org/"
4+
url "https://iojs.org/dist/v1.0.0/iojs-v1.0.0.tar.gz"
5+
sha256 "dcc6ccd99fffa20ebe59b35acca51150cfd68171cbf36fee210b3f5480964d05"
6+
7+
bottle do
8+
revision 1
9+
sha1 "a98a1df66cfb0712b14489186c46f7087ba35bd7" => :yosemite
10+
sha1 "0cd45412840a67d5d65e6bc3c0c3bcf8bc23153c" => :mavericks
11+
sha1 "977332381c033626b991002c27e738c144ebbaac" => :mountain_lion
12+
end
13+
14+
deprecated_option "enable-debug" => "with-debug"
15+
16+
option "with-debug", "Build with debugger hooks"
17+
option "without-npm", "npm will not be installed"
18+
option "without-completion", "npm bash completion will not be installed"
19+
20+
depends_on :python => :build
21+
22+
fails_with :llvm do
23+
build 2326
24+
end
25+
26+
resource "npm" do
27+
url "https://registry.npmjs.org/npm/-/npm-2.1.18.tgz"
28+
sha1 "e2af4c5f848fb023851cd2ec129005d33090bd57"
29+
end
30+
31+
def install
32+
args = %W{--prefix=#{prefix} --without-npm}
33+
args << "--debug" if build.with? "debug"
34+
35+
# This should eventually be able to use the system icu4c, but right now
36+
# it expects to find this dependency using pkgconfig.
37+
if build.head?
38+
ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["icu4c"].opt_prefix}/lib/pkgconfig"
39+
args << "--with-intl=system-icu"
40+
end
41+
42+
system "./configure", *args
43+
system "make", "install"
44+
45+
if build.with? "npm"
46+
resource("npm").stage buildpath/"npm_install"
47+
48+
# make sure npm can find iojs
49+
ENV.prepend_path "PATH", bin
50+
51+
# set log level temporarily for npm's `make install`
52+
ENV["NPM_CONFIG_LOGLEVEL"] = "verbose"
53+
54+
cd buildpath/"npm_install" do
55+
system "./configure", "--prefix=#{libexec}/npm"
56+
system "make", "install"
57+
end
58+
59+
if build.with? "completion"
60+
bash_completion.install \
61+
buildpath/"npm_install/lib/utils/completion.sh" => "npm"
62+
end
63+
end
64+
end
65+
66+
def post_install
67+
return if build.without? "npm"
68+
69+
node_modules = HOMEBREW_PREFIX/"lib/node_modules"
70+
node_modules.mkpath
71+
npm_exec = node_modules/"npm/bin/npm-cli.js"
72+
# Kill npm but preserve all other modules across iojs updates/upgrades.
73+
rm_rf node_modules/"npm"
74+
75+
cp_r libexec/"npm/lib/node_modules/npm", node_modules
76+
# This symlink doesn't hop into homebrew_prefix/bin automatically so
77+
# remove it and make our own. This is a small consequence of our bottle
78+
# npm make install workaround. All other installs **do** symlink to
79+
# homebrew_prefix/bin correctly. We ln rather than cp this because doing
80+
# so mimics npm's normal install.
81+
ln_sf npm_exec, "#{HOMEBREW_PREFIX}/bin/npm"
82+
83+
# Let's do the manpage dance. It's just a jump to the left.
84+
# And then a step to the right, with your hand on rm_f.
85+
["man1", "man3", "man5", "man7"].each do |man|
86+
rm_f Dir[HOMEBREW_PREFIX/"share/man/#{man}/{npm.,npm-,npmrc.}*"]
87+
Dir[libexec/"npm/share/man/#{man}/npm*"].each {|f| ln_sf f, HOMEBREW_PREFIX/"share/man/#{man}" }
88+
end
89+
90+
npm_root = node_modules/"npm"
91+
npmrc = npm_root/"npmrc"
92+
npmrc.atomic_write("prefix = #{HOMEBREW_PREFIX}\n")
93+
end
94+
95+
def caveats
96+
s = ""
97+
98+
if build.with? "npm"
99+
s += <<-EOS.undent
100+
If you update npm itself, do NOT use the npm update command.
101+
The upstream-recommended way to update npm is:
102+
npm install -g npm@latest
103+
EOS
104+
else
105+
s += <<-EOS.undent
106+
Homebrew has NOT installed npm. If you later install it, you should supplement
107+
your NODE_PATH with the npm module folder:
108+
#{HOMEBREW_PREFIX}/lib/node_modules
109+
EOS
110+
end
111+
112+
s
113+
end
114+
115+
test do
116+
path = testpath/"test.js"
117+
path.write "console.log('hello');"
118+
119+
output = `#{bin}/iojs #{path}`.strip
120+
assert_equal "hello", output
121+
assert_equal 0, $?.exitstatus
122+
123+
if build.with? "npm"
124+
# make sure npm can find node
125+
ENV.prepend_path "PATH", opt_bin
126+
assert_equal which("iojs"), opt_bin/"iojs"
127+
assert (HOMEBREW_PREFIX/"bin/npm").exist?, "npm must exist"
128+
assert (HOMEBREW_PREFIX/"bin/npm").executable?, "npm must be executable"
129+
system "#{HOMEBREW_PREFIX}/bin/npm", "--verbose", "install", "npm@latest"
130+
end
131+
end
132+
end

0 commit comments

Comments
 (0)