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

Commit 343f887

Browse files
committed
add iojs
1 parent 158c66d commit 343f887

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

Library/Formula/iojs.rb

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

Library/Formula/node.rb

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class Node < Formula
55
sha256 "0043656bb1724cb09dbdc960a2fd6ee37d3badb2f9c75562b2d11235daa40a03"
66
revision 2
77

8+
conflicts_with "iojs", :because => "io.js includes a symlink named node for compatibility."
9+
810
bottle do
911
revision 1
1012
sha1 "a98a1df66cfb0712b14489186c46f7087ba35bd7" => :yosemite

0 commit comments

Comments
 (0)