Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Adds flag to patch npm install for iojs compatibility #36357

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Library/Formula/iojs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ def install
end

def caveats; <<-EOS.undent
iojs was installed without npm.
iojs was installed without npm. To install npm with iojs compatability:
brew install node --with-iojs-patch

iojs currently requires a patched npm (i.e. not the npm installed by node).
To prepend iojs to your PATH add to your ~/.bashrc:
export PATH="#{Formula["iojs"].opt_bin}:$PATH"

This will also e.g. make npm use iojs's node.
EOS
end

Expand Down
39 changes: 35 additions & 4 deletions Library/Formula/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Node < Formula
option "with-debug", "Build with debugger hooks"
option "without-npm", "npm will not be installed"
option "without-completion", "npm bash completion will not be installed"
option "with-iojs-patch", "Patch npm for iojs compatibility"

depends_on :python => :build

Expand Down Expand Up @@ -73,22 +74,27 @@ def install
system "make", "install"

if build.with? "npm"
resource("npm").stage buildpath/"npm_install"

resource("npm").stage npm_buildpath = buildpath/"npm_install"
# make sure npm can find node
ENV.prepend_path "PATH", bin

# set log level temporarily for npm's `make install`
ENV["NPM_CONFIG_LOGLEVEL"] = "verbose"

cd buildpath/"npm_install" do
cd npm_buildpath do
if build.with? "iojs-patch"
p = Patch.create(:p1, :DATA)
p.path = Pathname.new(__FILE__).expand_path
p.apply
end

system "./configure", "--prefix=#{libexec}/npm"
system "make", "install"
end

if build.with? "completion"
bash_completion.install \
buildpath/"npm_install/lib/utils/completion.sh" => "npm"
npm_buildpath/"lib/utils/completion.sh" => "npm"
end
end
end
Expand Down Expand Up @@ -162,3 +168,28 @@ def caveats
end
end
end

__END__
diff --git a/node_modules/node-gyp/lib/install.js b/node_modules/node-gyp/lib/install.js
index 6f72e6a..ebc4e57 100644
--- a/node_modules/node-gyp/lib/install.js
+++ b/node_modules/node-gyp/lib/install.js
@@ -39,7 +39,7 @@ function install (gyp, argv, callback) {
}
}

- var distUrl = gyp.opts['dist-url'] || gyp.opts.disturl || 'http://nodejs.org/dist'
+ var distUrl = gyp.opts['dist-url'] || gyp.opts.disturl || 'https://iojs.org/dist'


// Determine which node dev files version we are installing
@@ -185,7 +185,7 @@ function install (gyp, argv, callback) {

// now download the node tarball
var tarPath = gyp.opts['tarball']
- var tarballUrl = tarPath ? tarPath : distUrl + '/v' + version + '/node-v' + version + '.tar.gz'
+ var tarballUrl = tarPath ? tarPath : distUrl + '/v' + version + '/iojs-v' + version + '.tar.gz'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch looks way too iojs specific; it's literally just overriding node urls with iojs ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be only temporary until node-gyp can decide where to download from on its own. This only touches the npm portion of the install and this is how npm devs are currently dealing with iojs compatibility. It also doesn't break joyent node compatibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather wait until this patch is accepted for this reason. It looks like it could cause issues if that node fallback is just removed.

, badDownload = false
, extractCount = 0
, gunzip = zlib.createGunzip()