build.js
function remove(file, options, done) {
    if (arguments.length === 2 && 'function' === typeof options) {
        done = options;
        options = {};
    }

    if ('function' !== typeof done) {
        done = function() {};
    }

    function callfile(file, stats, done) {
        fs.unlink(file, done);
    }

    function calldir(dir, stats, files, state, done) {
        if (state === 'end') {
            if (options.empty && dir === file) {
                done();
            } else {
                if (stats.isSymbolicLink()) {
                    fs.unlink(dir, done);
                } else {
                    fs.rmdir(dir, function(er) {
                        if (er && (er.code === 'ENOTEMPTY' || er.code === 'EEXIST' || er.code === 'EPERM')) {
                            // try in few time, last deletion is not completely ended
                            setTimeout(function() {
                                fs.rmdir(dir, done);
                            }, 10);
                        } else {
                            done(er);
                        }
                    });
                }
            }
        } else {
            done();
        }
    }

    options = Object.assign({
        fs: fs,
        resolve: true,
        followSymlink: false
    }, options);

    _explore(file, callfile, calldir, options, done);
}
function remove(file, options, done) {
    if (arguments.length === 2 && 'function' === typeof options) {
        done = options;
        options = {};
    }

    if ('function' !== typeof done) {
        done = function() {};
    }

    function callfile(file, stats, done) {
        fs.unlink(file, done);
    }

    function calldir(dir, stats, files, state, done) {
        if (state === 'end') {
            if (options.empty && dir === file) {
                done();
            } else {
                if (stats.isSymbolicLink()) {
                    fs.unlink(dir, done);
                } else {
                    fs.rmdir(dir, function(er) {
                        if (er && (er.code === 'ENOTEMPTY' || er.code === 'EEXIST' || er.code === 'EPERM')) {
                            // try in few time, last deletion is not completely ended
                            setTimeout(function() {
                                fs.rmdir(dir, done);
                            }, 10);
                        } else {
                            done(er);
                        }
                    });
                }
            }
        } else {
            done();
        }
    }

    options = Object.assign({
        fs: fs,
        resolve: true,
        followSymlink: false
    }, options);

    _explore(file, callfile, calldir, options, done);
}
function remove ( file , options , done ) { if ( arguments . length === 2 && 'function' === typeof options ) { done = options ; options = { } ; } if ( 'function' !== typeof done ) { done = function ( ) { } ; } function callfile ( file , stats , done ) { fs . unlink ( file , done ) ; } function calldir ( dir , stats , files , state , done ) { if ( state === 'end' ) { if ( options . empty && dir === file ) { done ( ) ; } else { if ( stats . isSymbolicLink ( ) ) { fs . unlink ( dir , done ) ; } else { fs . rmdir ( dir , function ( er ) { if ( er && ( er . code === 'ENOTEMPTY' || er . code === 'EEXIST' || er . code === 'EPERM' ) ) { // try in few time, last deletion is not completely ended setTimeout ( function ( ) { fs . rmdir ( dir , done ) ; } , 10 ) ; } else { done ( er ) ; } } ) ; } } } else { done ( ) ; } } options = Object . assign ( { fs : fs , resolve : true , followSymlink : false } , options ) ; _explore ( file , callfile , calldir , options , done ) ; }
rm -rf. Symlink are not resolved by default, avoiding unwanted deep deletion
there should be a way to do it with rimraf, but too much options digging to find a way to do it
@param  {String}   file or folder to remove
@param  {Function} done called on end
rm - rf . Symlink are not resolved by default avoiding unwanted deep deletion there should be a way to do it with rimraf but too much options digging to find a way to do it