homebrew-core/Formula/node@18.rb

121 lines
4.3 KiB
Ruby

class NodeAT18 < Formula
desc "Platform built on V8 to build network applications"
homepage "https://nodejs.org/"
url "https://nodejs.org/dist/v18.13.0/node-v18.13.0.tar.xz"
sha256 "fd4ac562e01d172896e3a959bd59552dbf647331c90d726f8d3471683dd3da68"
license "MIT"
livecheck do
url "https://nodejs.org/dist/"
regex(%r{href=["']?v?(18(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 arm64_ventura: "bf7802faf18c8372d1002910211f764b4e00b66fbaae5a7ba90d692c0de2f0d4"
sha256 arm64_monterey: "dca410f052307040f847a43daddee0cbcffec70be322647ce4e7002aea1d64df"
sha256 arm64_big_sur: "1aa888106d1efe72d29208dfaf24cfd69377dfd01307edc458fd8997a228a33f"
sha256 ventura: "b1da563c7df6cd7fe385e2abe4445e6771d6eb89c9cf8980a1b911fbfc306c90"
sha256 monterey: "b4946cb8f3978403e8a32080217dbebb59fe3767c5e59f3416032da25b79ae8b"
sha256 big_sur: "44d1a2ec07f3846f6b94f01511981c841a86bbb7254b3b8d58885e009e795e4d"
sha256 x86_64_linux: "c1feb1d6f7f7f287a129a42612b45ea6af8810a0ec2fda86ab8ddbd71a94dd3e"
end
keg_only :versioned_formula
# https://nodejs.org/en/about/releases/
# disable! date: "2025-04-30", because: :unsupported
deprecate! date: "2023-10-18", because: :unsupported
depends_on "pkg-config" => :build
# Bump to python@3.11 with node v18.13
# https://github.com/nodejs/node/commit/fee62ea05d6f958f5209a44df087efd25f356262
depends_on "python@3.10" => :build
depends_on "brotli"
depends_on "c-ares"
depends_on "icu4c"
depends_on "libnghttp2"
depends_on "libuv"
depends_on "openssl@1.1"
uses_from_macos "python", since: :catalina
uses_from_macos "zlib"
on_macos do
depends_on "llvm" => [:build, :test] if DevelopmentTools.clang_build_version <= 1100
end
fails_with :clang do
build 1100
cause <<~EOS
error: calling a private constructor of class 'v8::internal::(anonymous namespace)::RegExpParserImpl<uint8_t>'
EOS
end
fails_with gcc: "5"
def install
ENV.llvm_clang if OS.mac? && (DevelopmentTools.clang_build_version <= 1100)
# make sure subprocesses spawned by make are using our Python 3
ENV["PYTHON"] = which("python3.10")
args = %W[
--prefix=#{prefix}
--with-intl=system-icu
--shared-libuv
--shared-nghttp2
--shared-openssl
--shared-zlib
--shared-brotli
--shared-cares
--shared-libuv-includes=#{Formula["libuv"].include}
--shared-libuv-libpath=#{Formula["libuv"].lib}
--shared-nghttp2-includes=#{Formula["libnghttp2"].include}
--shared-nghttp2-libpath=#{Formula["libnghttp2"].lib}
--shared-openssl-includes=#{Formula["openssl@1.1"].include}
--shared-openssl-libpath=#{Formula["openssl@1.1"].lib}
--shared-brotli-includes=#{Formula["brotli"].include}
--shared-brotli-libpath=#{Formula["brotli"].lib}
--shared-cares-includes=#{Formula["c-ares"].include}
--shared-cares-libpath=#{Formula["c-ares"].lib}
--openssl-use-def-ca-store
]
system "./configure", *args
system "make", "install"
end
def post_install
(lib/"node_modules/npm/npmrc").atomic_write("prefix = #{HOMEBREW_PREFIX}\n")
end
test do
# Make sure Mojave does not have `CC=llvm_clang`.
ENV.clang if OS.mac?
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
output = shell_output("#{bin}/node -e 'console.log(new Intl.NumberFormat(\"de-DE\").format(1234.56))'").strip
assert_equal "1.234,56", output
# 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", "ref-napi" unless head?
assert_predicate bin/"npx", :exist?, "npx must exist"
assert_predicate bin/"npx", :executable?, "npx must be executable"
assert_match "< hello >", shell_output("#{bin}/npx --yes cowsay hello")
end
end