Skip to content

Commit

Permalink
Add our own npm.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Aug 23, 2024
1 parent 669cf6e commit 3356342
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions metacall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class Metacall < Formula
end
end

# We track major/minor from upstream Node releases.
# We will accept *important* npm patch releases when necessary.
resource "npm" do
url "https://registry.npmjs.org/npm/-/npm-10.8.2.tgz"
sha256 "c8c61ba0fa0ab3b5120efd5ba97fdaf0e0b495eef647a97c4413919eda0a878b"
end

def python
deps.map(&:to_formula)
.find { |f| f.name.match?(/^python@\d\.\d+$/) }
Expand Down Expand Up @@ -64,6 +71,23 @@ def install
# Add build folder to PATH in order to find node executable
ENV.prepend_path "PATH", bin

# Set NPM
bootstrap = buildpath/"npm_bootstrap"
bootstrap.install resource("npm")
# These dirs must exists before npm install.
mkdir_p libexec/"lib"
system "node", bootstrap/"bin/npm-cli.js", "install", "-ddd", "--global",
"--prefix=#{libexec}", resource("npm").cached_download

# The `package.json` stores integrity information about the above passed
# in `cached_download` npm resource, which breaks `npm -g outdated npm`.
# This copies back over the vanilla `package.json` to fix this issue.
cp bootstrap/"package.json", libexec/"lib/node_modules/npm"
# These symlinks are never used & they've caused issues in the past.
rm_r libexec/"share" if (libexec/"share").exist?

bash_completion.install bootstrap/"lib/utils/completion.sh" => "npm"

# Set the compiler
cc_compiler = `xcrun --find clang`.tr("\n","")
cxx_compiler = `xcrun --find clang++`.tr("\n","")
Expand Down

0 comments on commit 3356342

Please sign in to comment.