Skip to content
This repository was archived by the owner on Dec 20, 2017. It is now read-only.

Commit 7ebfaf6

Browse files
committed
Initial commit.
1 parent 008da3d commit 7ebfaf6

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

Aliases/io.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Formula/iojs.rb

Formula/iojs.rb

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Note that x.even are stable releases, x.odd are devel releases
2+
class Iojs < Formula
3+
homepage "https://iojs.org/"
4+
url "https://iojs.org/download/nightly/v1.0.0-nightly201501111b8f37bb4d/iojs-v1.0.0-nightly201501111b8f37bb4d.tar.gz"
5+
sha256 "c69edc1cdd13db6c98dc9c4af01d672bae69e1eca43f2d3bfa007c142e9255b3"
6+
revision 1
7+
8+
head do
9+
url "https://github.com/iojs/io.js.git", :branch => "v1.x"
10+
11+
depends_on "pkg-config" => :build
12+
depends_on "icu4c"
13+
end
14+
15+
deprecated_option "enable-debug" => "with-debug"
16+
17+
option "with-debug", "Build with debugger hooks"
18+
option "without-npm", "npm will not be installed"
19+
option "without-completion", "npm bash completion will not be installed"
20+
21+
depends_on :python => :build
22+
23+
fails_with :llvm do
24+
build 2326
25+
end
26+
27+
resource "npm" do
28+
url "https://registry.npmjs.org/npm/-/npm-2.1.17.tgz"
29+
sha1 "80fa7873188659037ec0ed8ebc95c2b2723c8ac4"
30+
end
31+
32+
def install
33+
args = %W{--prefix=#{prefix} --without-npm}
34+
args << "--debug" if build.with? "debug"
35+
36+
# This should eventually be able to use the system icu4c, but right now
37+
# it expects to find this dependency using pkgconfig.
38+
if build.head?
39+
ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["icu4c"].opt_prefix}/lib/pkgconfig"
40+
args << "--with-intl=system-icu"
41+
end
42+
43+
system "./configure", *args
44+
system "make", "install"
45+
46+
resource("npm").stage libexec/"npm" if build.with? "npm"
47+
end
48+
49+
def post_install
50+
return if build.without? "npm"
51+
52+
(libexec/"npm").cd { system "make", "uninstall" }
53+
Pathname.glob(HOMEBREW_PREFIX/"share/man/*") do |man|
54+
next unless man.directory?
55+
man.children.each do |file|
56+
next unless file.symlink?
57+
file.unlink if file.readlink.to_s.include? "/node_modules/npm/man/"
58+
end
59+
end
60+
61+
node_modules = HOMEBREW_PREFIX/"lib/node_modules"
62+
node_modules.mkpath
63+
cp_r libexec/"npm", node_modules
64+
65+
npm_root = node_modules/"npm"
66+
npmrc = npm_root/"npmrc"
67+
npmrc.atomic_write("prefix = #{HOMEBREW_PREFIX}\n")
68+
69+
# set log level temporarily for npm's `make install`
70+
ENV["NPM_CONFIG_LOGLEVEL"] = "verbose"
71+
72+
# make sure npm can find iojs
73+
ENV["PATH"] = "#{opt_bin}:#{ENV["PATH"]}"
74+
75+
ENV["NPM_CONFIG_USERCONFIG"] = npmrc
76+
npm_root.cd { system "make", "install" }
77+
78+
if build.with? "completion"
79+
bash_completion.install_symlink \
80+
npm_root/"lib/utils/completion.sh" => "npm"
81+
end
82+
end
83+
84+
def caveats
85+
s = ""
86+
87+
if build.with? "npm"
88+
s += <<-EOS.undent
89+
If you update npm itself, do NOT use the npm update command.
90+
The upstream-recommended way to update npm is:
91+
npm install -g npm@latest
92+
EOS
93+
else
94+
s += <<-EOS.undent
95+
Homebrew has NOT installed npm. If you later install it, you should supplement
96+
your NODE_PATH with the npm module folder:
97+
#{HOMEBREW_PREFIX}/lib/node_modules
98+
EOS
99+
end
100+
101+
s
102+
end
103+
104+
test do
105+
path = testpath/"test.js"
106+
path.write "console.log('hello');"
107+
108+
output = `#{bin}/iojs #{path}`.strip
109+
assert_equal "hello", output
110+
assert_equal 0, $?.exitstatus
111+
112+
if build.with? "npm"
113+
# make sure npm can find iojs
114+
ENV.prepend_path "PATH", opt_bin
115+
assert_equal which("iojs"), opt_bin/"iojs"
116+
assert (HOMEBREW_PREFIX/"bin/npm").exist?, "npm must exist"
117+
assert (HOMEBREW_PREFIX/"bin/npm").executable?, "npm must be executable"
118+
system "#{HOMEBREW_PREFIX}/bin/npm", "--verbose", "install", "npm@latest"
119+
end
120+
end
121+
end

0 commit comments

Comments
 (0)