Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hughsk committed Aug 12, 2012
0 parents commit 15b5c55
Show file tree
Hide file tree
Showing 18 changed files with 1,471 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# npm-quickfix

Super quick fix for NPM registry, without having to actually mirror anything. Thanks to @framp for pointing out the workaround.

``` bash
git clone [email protected]:npm-quickfix.git
cd npm-quickfix
npm set registry http://localhost:8080/
node index.js
```

Now you should be able to `npm install` as normal :)

To change back to the original registry:

``` bash
npm set registry https://registry.npmjs.org/
```
33 changes: 33 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var http = require('http')
, url = require('url')
, request = require('request');

http.createServer(function(req, res) {
var file = url.parse(req.url).path;

if (!file.match(/\.tgz$/g)) {
return request.get('https://registry.npmjs.org' + req.url, function(err, response, body) {
var body = JSON.parse(body)
, versions = body.versions
, name = body.name;

console.log(require('util').inspect(body, null, null, null));

if (body.dist && body.dist.tarball) body.dist.tarball = body.dist.tarball
.replace(/http(s)?\:\/\/registry.npmjs.org\/\-\//,
'https://registry.npmjs.org/' + name + '/-/'
);

if (versions) Object.keys(versions).forEach(function(version) {
versions[version].dist.tarball = versions[version].dist.tarball
.replace(/http(s)?\:\/\/registry.npmjs.org\/\-\//,
'https://registry.npmjs.org/' + name + '/-/'
);
});

res.end(JSON.stringify(body));
});
}

request.get('https://registry.npmjs.org' + req.url).pipe(res);
}).listen(8080);
55 changes: 55 additions & 0 deletions node_modules/request/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

191 changes: 191 additions & 0 deletions node_modules/request/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 15b5c55

Please sign in to comment.