class NodeAT4 < Formula desc "Platform built on V8 to build network applications" homepage "https://nodejs.org/" url "https://nodejs.org/dist/v4.8.7/node-v4.8.7.tar.xz" sha256 "03479a8ce6affedde75d80a6c8c351a7afb5a85b8d7e5119ab6f349100e641f8" revision 1 head "https://github.com/nodejs/node.git", :branch => "v4.x-staging" bottle do sha256 "86663e524c4842d9a6d74bd1ade9d3fbf0040de5eb2c5aef5d95d7aadbc49742" => :high_sierra sha256 "40f84a7f145f6018561b88fa9b788ca004e1e8d8cd5691eca0835f779c775f25" => :sierra sha256 "67669e0465b6b6e1591dbe849da9504502cda65de4b0cf6f09d554533613b4b5" => :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 <<~EOS prefix = #{HOMEBREW_PREFIX} python = /usr/bin/python EOS 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