homebrew-core/Formula/node@12.rb

79 lines
3.1 KiB
Ruby

class NodeAT12 < Formula
desc "Platform built on V8 to build network applications"
homepage "https://nodejs.org/"
url "https://nodejs.org/dist/v12.22.6/node-v12.22.6.tar.gz"
sha256 "02763dcf6532a997143b03c1f7d23552a3bd19ddcad1fd2425956db7596cbc9c"
license "MIT"
livecheck do
url "https://nodejs.org/dist/"
regex(%r{href=["']?v?(12(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 cellar: :any, arm64_big_sur: "d3010f414ec59c92041a1035bfeea9dd08cd6cc472b1fd1394f4447902eb63c6"
sha256 cellar: :any, big_sur: "caf8395437c1c70c12285eac366ef5e1f03db9c0b5640242156591c45ddfeffb"
sha256 cellar: :any, catalina: "b86fe87aa75996f8739e87ffe6d021ba5f9d04868dc664e353eb02c7c43a7b92"
sha256 cellar: :any, mojave: "00b0f21bbb02df305c4536022f0ded5564eb9b783946516b9d961428ebd7b5aa"
sha256 cellar: :any_skip_relocation, x86_64_linux: "3671baccbe7dafa45d35cfff1991fa89a1fa70555ff1c04073d72fa6cc43038f"
end
keg_only :versioned_formula
depends_on "pkg-config" => :build
depends_on "python@3.9" => :build
depends_on "icu4c"
on_macos do
depends_on "macos-term-size"
end
def install
# make sure subprocesses spawned by make are using our Python 3
ENV["PYTHON"] = Formula["python@3.9"].opt_bin/"python3"
system "python3", "configure.py", "--prefix=#{prefix}", "--with-intl=system-icu"
system "make", "install"
term_size_vendor_dir = lib/"node_modules/npm/node_modules/term-size/vendor"
term_size_vendor_dir.rmtree # remove pre-built binaries
if OS.mac?
macos_dir = term_size_vendor_dir/"macos"
macos_dir.mkpath
# Replace the vendored pre-built term-size with one we build ourselves
ln_sf (Formula["macos-term-size"].opt_bin/"term-size").relative_path_from(macos_dir), macos_dir
end
end
def post_install
(lib/"node_modules/npm/npmrc").atomic_write("prefix = #{HOMEBREW_PREFIX}\n")
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
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", "bufferutil"
assert_predicate bin/"npx", :exist?, "npx must exist"
assert_predicate bin/"npx", :executable?, "npx must be executable"
assert_match "< hello >", shell_output("#{bin}/npx cowsay hello")
end
end