Skip to content

Commit

Permalink
added "install" to command ot install a package and "list"
Browse files Browse the repository at this point in the history
command to list the installed packages
  • Loading branch information
dangoor committed Apr 17, 2009
1 parent 56bbbb3 commit 18afc37
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/getjs/commands.js
@@ -1,6 +1,7 @@
var file = require("file");
var log = require("getjs/logger").log;
var WorkingEnv = require("getjs/workingenv").WorkingEnv;
var Installer = require("getjs/install").Installer;

var Command = function() {

Expand Down Expand Up @@ -83,3 +84,42 @@ exports.clearrepo.prototype = {
}
}

exports.install = function(args) {
this.names = args;
}

exports.install.prototype = {
description: "Install packages",
run: function(env) {
var installer = new Installer(env);
var names = this.names;
var downloadinfos = [];

for (var i = 0; i < names.length; i++) {
var name = names[i];
log.info("Downloading " + name);
downloadinfos.push(installer.download(name));
}

for (i = 0; i < downloadinfos.length; i++) {
var di = downloadinfos[i];
log.info("Installing " + name);
installer.install(di.pack, di.packFile, di.sourceFile);
}
}
}

exports.list = function(args) {

}

exports.list.prototype = {
description: "List installed packages",
run: function(env) {
var packages = env.getInstalledPackages();
for (var name in packages) {
var pack = packages[name];
log.info(pack.name + " " + pack.version.label);
}
}
}

0 comments on commit 18afc37

Please sign in to comment.