lib/util.js
function rm(filepath, callback) {
    var killswitch = false;
    fs.stat(filepath, function(err, stat) {
        if (err) return callback(err);
        if (stat.isFile()) return fs.unlink(filepath, callback);
        if (!stat.isDirectory()) return callback(new Error('Unrecognized file.'));
        Step(function() {
            fs.readdir(filepath, this);
        },
        function(err, files) {
            if (err) throw err;
            if (files.length === 0) return this(null, []);
            var group = this.group();
            _(files).each(function(file) {
                rm(path.join(filepath, file), group());
            });
        },
        function(err) {
            if (err) return callback(err);
            fs.rmdir(filepath, callback);
        });
    });
}
function rm(filepath, callback) {
    var killswitch = false;
    fs.stat(filepath, function(err, stat) {
        if (err) return callback(err);
        if (stat.isFile()) return fs.unlink(filepath, callback);
        if (!stat.isDirectory()) return callback(new Error('Unrecognized file.'));
        Step(function() {
            fs.readdir(filepath, this);
        },
        function(err, files) {
            if (err) throw err;
            if (files.length === 0) return this(null, []);
            var group = this.group();
            _(files).each(function(file) {
                rm(path.join(filepath, file), group());
            });
        },
        function(err) {
            if (err) return callback(err);
            fs.rmdir(filepath, callback);
        });
    });
}
function rm ( filepath , callback ) { var killswitch = false ; fs . stat ( filepath , function ( err , stat ) { if ( err ) return callback ( err ) ; if ( stat . isFile ( ) ) return fs . unlink ( filepath , callback ) ; if ( ! stat . isDirectory ( ) ) return callback ( new Error ( 'Unrecognized file.' ) ) ; Step ( function ( ) { fs . readdir ( filepath , this ) ; } , function ( err , files ) { if ( err ) throw err ; if ( files . length === 0 ) return this ( null , [ ] ) ; var group = this . group ( ) ; _ ( files ) . each ( function ( file ) { rm ( path . join ( filepath , file ) , group ( ) ) ; } ) ; } , function ( err ) { if ( err ) return callback ( err ) ; fs . rmdir ( filepath , callback ) ; } ) ; } ) ; }
Recursive rm.
Recursive rm .