homebrew-core/Formula/node@4.rb
2018-03-29 21:44:07 -07:00

87 lines
3.1 KiB
Ruby

class NodeAT4 < Formula
desc "Platform built on V8 to build network applications"
homepage "https://nodejs.org/"
url "https://nodejs.org/dist/v4.9.1/node-v4.9.1.tar.xz"
sha256 "d7d1232f948391699c6e98780ac90bdf5889902d639bad41561ac29f03dad401"
head "https://github.com/nodejs/node.git", :branch => "v4.x-staging"
bottle do
sha256 "57fc2a966bc0fb00106bfe006c78e87629c92148bfefcc48abba257ebfc375fe" => :high_sierra
sha256 "4fbaa797a7605cf388bd38cfb272d0a495398fbbdd12ae6b502512d7d3e95118" => :sierra
sha256 "ed69a9cfabb22cdb1390fc86dd6c5d54308a17af8be74fe669cd7b129b163956" => :el_capitan
end
keg_only :versioned_formula
option "with-debug", "Build with debugger hooks"
option "with-openssl", "Build against Homebrew's OpenSSL instead of the bundled OpenSSL"
option "without-npm", "npm will not be installed"
option "without-completion", "npm bash completion will not be installed"
option "with-full-icu", "Build with full-icu (all locales) instead of small-icu (English only)"
depends_on "python@2" => :build if MacOS.version <= :snow_leopard
depends_on "pkg-config" => :build
depends_on "openssl" => :optional
resource "icu4c" do
url "https://ssl.icu-project.org/files/icu4c/58.2/icu4c-58_2-src.tgz"
version "58.2"
sha256 "2b0a4410153a9b20de0e20c7d8b66049a72aef244b53683d0d7521371683da0c"
end
def install
args = ["--prefix=#{prefix}"]
args << "--without-npm" if build.without? "npm"
args << "--debug" if build.with? "debug"
args << "--shared-openssl" if build.with? "openssl"
if build.with? "full-icu"
args << "--with-intl=full-icu"
else
args << "--with-intl=small-icu"
end
args << "--tag=head" if build.head?
resource("icu4c").stage buildpath/"deps/icu"
system "./configure", *args
system "make", "install"
end
def post_install
return if build.without? "npm"
(lib/"node_modules/npm/npmrc").atomic_write("prefix = #{HOMEBREW_PREFIX}\n")
end
def caveats
if build.without? "npm"
<<~EOS
Homebrew has NOT installed npm. If you later install it, you should supplement
your NODE_PATH with the npm module folder:
#{HOMEBREW_PREFIX}/lib/node_modules
EOS
end
end
test do
path = testpath/"test.js"
path.write "console.log('hello');"
output = shell_output("#{bin}/node #{path}").strip
assert_equal "hello", output
output = shell_output("#{bin}/node -e 'console.log(new Intl.NumberFormat(\"en-EN\").format(1234.56))'").strip
assert_equal "1,234.56", output
if build.with? "npm"
# make sure npm can find node
ENV.prepend_path "PATH", opt_bin
ENV.delete "NVM_NODEJS_ORG_MIRROR"
assert_equal which("node"), opt_bin/"node"
assert_predicate bin/"npm", :exist?, "npm must exist"
assert_predicate bin/"npm", :executable?, "npm must be executable"
npm_args = ["-ddd", "--cache=#{HOMEBREW_CACHE}/npm_cache", "--build-from-source"]
system "#{bin}/npm", *npm_args, "install", "npm@latest"
system "#{bin}/npm", *npm_args, "install", "bignum" unless head?
end
end
end