homebrew-core/Formula/node@14.rb

79 lines
3.1 KiB
Ruby

class NodeAT14 < Formula
desc "Platform built on V8 to build network applications"
homepage "https://nodejs.org/"
url "https://nodejs.org/dist/v14.17.6/node-v14.17.6.tar.gz"
sha256 "f64559c87faa2f1ce93c3d2cd09723af254ec320a53cbfd1a2ba8fba28e488d0"
license "MIT"
livecheck do
url "https://nodejs.org/dist/"
regex(%r{href=["']?v?(14(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 cellar: :any, arm64_big_sur: "41d3ab74c536b1c88e15df92e1991d64e7d7f8f845555074ee61b7d4fa8f5c9c"
sha256 cellar: :any, big_sur: "cd0c93868bf70ac6a51e2ea7e7ca52d405dba808a35564625695d5385402c289"
sha256 cellar: :any, catalina: "32b944c89b4274a5eb5053b84d540e012043f1b41cf096133739d2fab9784beb"
sha256 cellar: :any, mojave: "503373b72c753e8eb3506a962f52e861221ba375cc40720aa46bec002fc5900d"
sha256 cellar: :any_skip_relocation, x86_64_linux: "e937005988d228479d4ee5825aacf2769e467286836eae790c032a83981fae6d"
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