node: fixes npm -g outdated/update npm
Fixes #15804. Closes #15807. Signed-off-by: ilovezfs <ilovezfs@icloud.com>
This commit is contained in:
parent
0abac0adca
commit
ca9e3f176d
1 changed files with 12 additions and 2 deletions
|
@ -3,6 +3,7 @@ class Node < Formula
|
|||
homepage "https://nodejs.org/"
|
||||
url "https://nodejs.org/dist/v8.2.0/node-v8.2.0.tar.xz"
|
||||
sha256 "4ce8975176630eb60cc8da256a6039e1d3d0e8bed472948a83ed4f22e8134781"
|
||||
revision 1
|
||||
head "https://github.com/nodejs/node.git"
|
||||
|
||||
bottle do
|
||||
|
@ -59,6 +60,11 @@ class Node < Formula
|
|||
bootstrap.install resource("npm")
|
||||
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_rf libexec/"share"
|
||||
|
||||
|
@ -130,8 +136,12 @@ class Node < Formula
|
|||
assert_equal which("node"), opt_bin/"node"
|
||||
assert (HOMEBREW_PREFIX/"bin/npm").exist?, "npm must exist"
|
||||
assert (HOMEBREW_PREFIX/"bin/npm").executable?, "npm must be executable"
|
||||
system "#{HOMEBREW_PREFIX}/bin/npm", "--verbose", "install", "npm@latest"
|
||||
system "#{HOMEBREW_PREFIX}/bin/npm", "--verbose", "install", "bignum" unless head?
|
||||
npm_args = ["-ddd", "--cache=#{HOMEBREW_CACHE}/npm_cache", "--build-from-source"]
|
||||
system "#{HOMEBREW_PREFIX}/bin/npm", *npm_args, "install", "npm@latest"
|
||||
system "#{HOMEBREW_PREFIX}/bin/npm", *npm_args, "install", "bignum" unless head?
|
||||
assert (HOMEBREW_PREFIX/"bin/npx").exist?, "npx must exist"
|
||||
assert (HOMEBREW_PREFIX/"bin/npx").executable?, "npx must be executable"
|
||||
assert_match "< hello >", shell_output("#{HOMEBREW_PREFIX}/bin/npx --cache=#{HOMEBREW_CACHE}/npm_cache cowsay hello")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue