Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions Formula/n/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
class NodeAT22 < Formula
desc "Platform built on V8 to build network applications"
homepage "https://nodejs.org/"
url "https://nodejs.org/dist/v22.10.0/node-v22.10.0.tar.xz"
sha256 "3180710d3130ad9df01466abf010e408d41b374be54301d1480d10eca73558e0"
license "MIT"

livecheck do
url "https://nodejs.org/dist/"
regex(%r{href=["']?v?(22(?:\.\d+)+)/?["' >]}i)
end

bottle do
sha256 arm64_sequoia: "528222d35a5ae846cd673c0b91a77e6fa3050d2de0c94091cd1b6c4a39656855"
sha256 arm64_sonoma: "53825ab98fe302132d5dafe83eb0c10d8d46ebdc8c8a1fb388cf8457d8aa3015"
sha256 arm64_ventura: "68baa5fc58da403c1814e3bec8672d51e355de633f0021b23250c6d06f52f42b"
sha256 sonoma: "f6bb645a21a91bbe99c9218e4122afa78e2714332be2adc84092cf422eb195cd"
sha256 ventura: "80345d2d38bc6feb5c6134abe390cb527525854859a2b2386c715d026cac7509"
sha256 x86_64_linux: "022797bdca863afb7a3ae77ea096fca338e2f75b613355f75e649618388b21bf"
end

keg_only :versioned_formula

# https://github.com/nodejs/release#release-schedule
# disable! date: "2027-04-30", because: :unsupported
deprecate! date: "2026-10-28", because: :unsupported

depends_on "pkg-config" => :build
depends_on "[email protected]" => :build
depends_on "brotli"
depends_on "c-ares"
depends_on "icu4c@75"
depends_on "libnghttp2"
depends_on "libuv"
depends_on "openssl@3"

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)

# The new linker crashed during LTO due to high memory usage.
ENV.append "LDFLAGS", "-Wl,-ld_classic" if DevelopmentTools.clang_build_version >= 1500

# make sure subprocesses spawned by make are using our Python 3
ENV["PYTHON"] = which("python3.13")

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@3"].include}
--shared-openssl-libpath=#{Formula["openssl@3"].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
]

# Enabling LTO errors on Linux with:
# terminate called after throwing an instance of 'std::out_of_range'
# Pre-Catalina macOS also can't build with LTO
# LTO is unpleasant if you have to build from source.
args << "--enable-lto" if OS.mac? && MacOS.version >= :catalina && build.bottle?

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", "nan"
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