Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
add some comments to the clean command module
Browse files Browse the repository at this point in the history
  • Loading branch information
Caolan McMahon committed Feb 28, 2012
1 parent 4e80e09 commit 95ee791
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/commands/clean.js
Expand Up @@ -103,6 +103,13 @@ exports.clean = function (dir, opt, callback) {
};


/**
* Delete multiple directory paths.
*
* @param {Array} dirs
* @param {Function} callback
*/

exports.deleteDirs = function (dirs, callback) {
async.forEach(dirs, function (d, cb) {
utils.rm('-rf', d, cb);
Expand All @@ -111,6 +118,15 @@ exports.deleteDirs = function (dirs, callback) {
};


/**
* Discover package directories that do not form part of the current
* package version tree.
*
* @param {String} dir - the root package dir
* @param {Object} opt - the options object
* @param {Function} callback
*/

exports.unusedDirs = function (dir, opt, callback) {
settings.load(dir, function (err, cfg) {
if (err) {
Expand All @@ -134,6 +150,15 @@ exports.unusedDirs = function (dir, opt, callback) {
};


/**
* Lists packages in the package dir and compares against the provided
* version tree, returning the packages not in the tree.
*
* @param {Object} packages - version tree
* @param {Object} opt - options object
* @param {Function} callback
*/

exports.unusedDirsTree = function (packages, opt, callback) {
exports.listDirs(opt.target_dir, function (err, dirs) {
if (err) {
Expand All @@ -152,6 +177,13 @@ exports.unusedDirsTree = function (packages, opt, callback) {
};


/**
* List directories within a directory. Filters out regular files etc.
*
* @param {String} dir
* @param {Function} callback
*/

exports.listDirs = function (dir, callback) {
fs.readdir(dir, function (err, files) {
if (err) {
Expand All @@ -173,6 +205,14 @@ exports.listDirs = function (dir, callback) {
};


/**
* Checks if a path is a directory, returns an object containing the
* checked path and a boolean for whether it's a directory.
*
* @param {String} path
* @param {Function} callback
*/

exports.isDir = function (path, callback) {
fs.stat(path, function (err, info) {
if (err) {
Expand Down

0 comments on commit 95ee791

Please sign in to comment.