Skip to content

Commit

Permalink
tusk install --force
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Robinson committed Oct 27, 2009
1 parent abf5be6 commit e403179
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/narwhal/tusk/install.js
Expand Up @@ -14,11 +14,10 @@ parser.help('downloads and installs a package and its dependencies');

parser.args('package');

/*
parser.option('-f', '--force', 'force')
.bool()
.help('causes packages to be installed in the project packages directory regardless of whether they are installed elsewhere');
/*
parser.option('-l', '--lean', 'lean')
.bool()
.help('causes only the essential components of the library to be installed.');
Expand Down Expand Up @@ -116,7 +115,7 @@ exports.install = function (options, names) {
}

// note missing packages
var missing = exports.missing(packages.catalog, dependencies);
var missing = exports.missing(packages.catalog, dependencies, options);
if (!missing.length) {
print('No new packages to install.');
this.exit();
Expand Down Expand Up @@ -155,6 +154,14 @@ exports.install = function (options, names) {
notes[name].requester = "module";
try {
var targetPath = tusk.getDirectory().join('packages', name);
if (targetPath.exists()) {
if (options.force) {
targetPath.rmtree();
} else {
print("Error: Directory exists: "+targetPath);
return;
}
}

var components = catalog.packages[name].location.match(/^file:\/\/(.*)$/);
if (components) {
Expand Down Expand Up @@ -265,7 +272,9 @@ exports.already = function (catalog, names) {
});
};

exports.missing = function (catalog, names) {
exports.missing = function (catalog, names, options) {
if (options.force)
return names;
return names.filter(function (packageName) {
return !util.has(catalog, packageName);
});
Expand Down

0 comments on commit e403179

Please sign in to comment.