node@18 18.12.0 (new formula)

node@18: use local npm

Closes #113826.

Co-authored-by: Alexander M. Turek <me@derrabus.de>
Signed-off-by: Rui Chen <rui@chenrui.dev>
Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
master
Sean Molenaar 2022-10-20 10:44:26 +02:00 committed by BrewTestBot
parent f0ed8a5f2a
commit 7ac5a5051c
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
2 changed files with 108 additions and 1 deletions

View File

@ -1 +0,0 @@
../Formula/node.rb

108
Formula/node@18.rb Normal file
View File

@ -0,0 +1,108 @@
class NodeAT18 < Formula
desc "Platform built on V8 to build network applications"
homepage "https://nodejs.org/"
url "https://nodejs.org/dist/v18.12.0/node-v18.12.0.tar.xz"
sha256 "73a7f01e2999eb197763ced666a6cd544ad580eaefb73e0a849603b3e804f42e"
license "MIT"
livecheck do
url "https://nodejs.org/dist/"
regex(%r{href=["']?v?(18(?:\.\d+)+)/?["' >]}i)
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
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