Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/npm.js
diff options
context:
space:
mode:
authorisaacs <i@foohack.com>2009-10-03 22:20:28 +0400
committerisaacs <i@foohack.com>2009-10-03 22:20:28 +0400
commitc161df1056a507256f35e803083eaad30ee23bdc (patch)
tree2767067485c99f1fa9281c2912fe1532c1b7b1a0 /npm.js
parent1b28b3f71bf1aab7ee6f0c3fbb68ec3eefd74faa (diff)
Putting too much stuff in here. It's sort of fetching the tarballs, but not actualy saving the files. Going to abstract that bit out, since I'm doing it twice now.
Diffstat (limited to 'npm.js')
-rwxr-xr-xnpm.js52
1 files changed, 35 insertions, 17 deletions
diff --git a/npm.js b/npm.js
index 9c1b31449..e0d0afea5 100755
--- a/npm.js
+++ b/npm.js
@@ -64,10 +64,39 @@ npm.installPackages = function npm_installPackages (set, opt) {
function _install (name, data, opt) {
var p = new node.Promise();
- setTimeout(function () {
- log("@todo: install for " + JSON.stringify(name));
- p.emitSuccess();
- });
+ log("");
+ log("installing " + name);
+ // fetch the tarball
+ var tarball = data.tarball;
+ // don't use http.cat, because it might be pretty large.
+ var uri = http.parseUri(tarball);
+ log("fetch: "+tarball);
+
+ http
+ .createClient(uri.port || (uri.protocol === "https" ? 443 : 80), uri.host)
+ .get(uri.path || "/", {Host:uri.host,"User-Agent":"npm"})
+ .finish(function (response) {
+ response.setBodyEncoding("utf8");
+ response.addListener("body", function (chunk) {
+ // write the chunk...
+ log("got a chunk of body");
+ });
+ response.addListener("error", function () {
+ log("failure: could not download "+tarball);
+ p.emitError();
+ });
+ response.addListener("complete", function () {
+ log("downloaded: "+tarball);
+ p.emitSuccess();
+ });
+ });
+
+ // unpack in $HOME/.node_libraries/<package>/
+ // If it's got a build step, then cd into the folder, and run it.
+ // if it's a lib, then write ~/.node_libraries/<package>.js as
+ // exports = require(<package>/<lib.js>)
+ // If it's got a start step, then run the start command.
+ // p.emitSuccess();
return p;
};
@@ -78,7 +107,7 @@ npm.install = function npm_install (pkg, opt) {
buildInstallSet(pkg)
.addErrback(fail(p,"Failed building requirements for "+pkg))
.addCallback(function (set) {
- log("Install set: "+JSON.stringify(set));
+ // log("Install set: "+JSON.stringify(set));
npm.installPackages(set, opt)
.addErrback(fail(p, "Failed to install"))
.addCallback(function () {
@@ -86,18 +115,7 @@ npm.install = function npm_install (pkg, opt) {
p.emitSuccess();
});
});
- // recurse through dependencies, then for each:
- // fetch the tarball
- // unpack in $HOME/.node_libraries/<package>/
- // If it's got a build step, then cd into the folder, and run it.
- // if it's a lib, then write ~/.node_libraries/<package>.js as
- // exports = require(<package>/<lib.js>)
- // If it's got a start step, then run the start command.
-
-
-
-
-
+
return p;
};