From 3a96af9af3f28d4a0d6d22fe886108f76e16d243 Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Wed, 3 Mar 2010 11:53:18 -0800 Subject: [PATCH] Fix "tusk clone" and readSources() --- lib/narwhal/tusk.js | 2 +- lib/narwhal/tusk/commands/clone.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/narwhal/tusk.js b/lib/narwhal/tusk.js index a1ebb534..212be22c 100644 --- a/lib/narwhal/tusk.js +++ b/lib/narwhal/tusk.js @@ -128,7 +128,7 @@ exports.readSources = function () { "sources file is out of date. version " + exports.minCatalogVersion + " is required." ); - sources.packages = sources.packages || {}; + sources.sources = sources.sources || {}; return sources; }; diff --git a/lib/narwhal/tusk/commands/clone.js b/lib/narwhal/tusk/commands/clone.js index 8da5dbc0..65dde592 100644 --- a/lib/narwhal/tusk/commands/clone.js +++ b/lib/narwhal/tusk/commands/clone.js @@ -21,22 +21,27 @@ parser.option('-u', '--user', 'user') .help('overrides the user name from which to clone the package') .set(); + parser.action(function (options) { + exports.clone.call(this, options, options.args); +}); + +exports.clone = function (options, names) { var self = this; - if (!util.len(options.args)) + if (!util.len(names)) throw new Error("Package name required"); var packagesDirectory = tusk.getPackagesDirectory(); - var sources = tusk.readSources().packages; + var sources = tusk.readSources().sources; var catalog = tusk.readCatalog().packages; var owner = options.owner; - options.args.forEach(function (name) { + names.forEach(function (name) { if (!util.has(sources, name)) throw new Error("Package does not exist: " + name); var source = util.get(sources, name); if (source.type !== "github") throw new Error("Package " + util.enquote(name) + " is not a Github package."); }); - options.args.forEach(function (name) { + names.forEach(function (name) { var source = util.get(sources, name); var githubName = util.get(source, 'name', name); var user = options.user || source.user; @@ -62,7 +67,7 @@ parser.action(function (options) { }).join(' ') + '\0)'); os.system(command); }); -}); +}; parser.helpful();