This repository has been archived by the owner on Jul 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Homebrew should no longer manage npm. #27479
Closed
Closed
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2caa4d3
npm/npm#3794
eac75f6
I guess the curl script fails due to 301 redirect. Modifying.
cf17263
Added link to unix fancy install section for npm. npm/npm#4867
75c6d40
Fixing syntax errors.
1c762e7
I believe I still had the syntax incorrect.
802f754
More syntax issues.
af456d1
Removed some whitespace.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,5 @@ | ||
require 'formula' | ||
|
||
class NpmRequirement < Requirement | ||
fatal true | ||
|
||
def modules_folder | ||
"#{HOMEBREW_PREFIX}/lib/node_modules" | ||
end | ||
|
||
def message; <<-EOS.undent | ||
Beginning with 0.8.0, this recipe now comes with npm. | ||
It appears you already have npm installed at #{modules_folder}/npm. | ||
To use the npm that comes with this recipe, first uninstall npm with | ||
`npm uninstall npm -g`, then run this command again. | ||
|
||
If you would like to keep your installation of npm instead of | ||
using the one provided with homebrew, install the formula with | ||
the `--without-npm` option. | ||
EOS | ||
end | ||
|
||
satisfy :build_env => false do | ||
begin | ||
path = Pathname.new("#{modules_folder}/npm/bin/npm") | ||
path.realpath.to_s.include?(HOMEBREW_CELLAR) | ||
rescue Errno::ENOENT | ||
true | ||
end | ||
end | ||
end | ||
|
||
# Note that x.even are stable releases, x.odd are devel releases | ||
class Node < Formula | ||
homepage 'http://nodejs.org/' | ||
|
@@ -43,10 +14,7 @@ class Node < Formula | |
head 'https://github.com/joyent/node.git' | ||
|
||
option 'enable-debug', 'Build with debugger hooks' | ||
option 'without-npm', 'npm will not be installed' | ||
option 'without-completion', 'npm bash completion will not be installed' | ||
|
||
depends_on NpmRequirement => :recommended | ||
depends_on :python | ||
|
||
fails_with :llvm do | ||
|
@@ -57,49 +25,17 @@ def install | |
args = %W{--prefix=#{prefix}} | ||
|
||
args << "--debug" if build.include? 'enable-debug' | ||
args << "--without-npm" if build.without? "npm" | ||
|
||
system "./configure", *args | ||
system "make install" | ||
|
||
if build.with? "npm" | ||
(lib/"node_modules/npm/npmrc").write("prefix = #{npm_prefix}\n") | ||
|
||
# Link npm manpages | ||
Pathname.glob("#{lib}/node_modules/npm/man/*").each do |man| | ||
dir = send(man.basename) | ||
man.children.each do |file| | ||
dir.install_symlink(file.relative_path_from(dir)) | ||
end | ||
end | ||
|
||
if build.with? "completion" | ||
bash_completion.install_symlink \ | ||
lib/"node_modules/npm/lib/utils/completion.sh" => "npm" | ||
end | ||
end | ||
end | ||
|
||
def npm_prefix | ||
d = "#{HOMEBREW_PREFIX}/share/npm" | ||
if File.directory? d | ||
d | ||
else | ||
HOMEBREW_PREFIX.to_s | ||
end | ||
end | ||
|
||
def caveats | ||
if build.without? "npm"; <<-end.undent | ||
Homebrew has NOT installed npm. If you later install it, you should supplement | ||
your NODE_PATH with the npm module folder: | ||
#{npm_prefix}/lib/node_modules | ||
end | ||
elsif not ENV['PATH'].split(':').include? "#{npm_prefix}/bin"; <<-end.undent | ||
Probably you should amend your PATH to include npm-installed binaries: | ||
#{npm_prefix}/bin | ||
end | ||
end | ||
def caveats; <<-end.undent | ||
Homebrew has NOT installed npm. If you want npm (you do right?) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would absolutely rather we provide a link to a webpage that provides these instructions, so the caveats would be "To install npm, read the instructions at http://blah." |
||
then view the install instructions here: | ||
|
||
https://www.npmjs.org/doc/README.html#Fancy-Install-Unix | ||
|
||
It's easy. | ||
end | ||
|
||
test do | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
EOS.undent
and put in the endingEOS
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. Thank you :)