index.js
function rmdirSyncRecursive(root, chunks) {

  var chunk = chunks.pop();
  if (!chunk) {
    return;
  }
  var pathname = path.join(root, '..'); // backtrack

  if (fs.existsSync(root) === false) { // already done
    return rmdirSyncRecursive(root, chunks);
  }
  var err = fs.rmdirSync(root);
  return err ? err : rmdirSyncRecursive(pathname, chunks); // let's magic
}
function rmdirSyncRecursive(root, chunks) {

  var chunk = chunks.pop();
  if (!chunk) {
    return;
  }
  var pathname = path.join(root, '..'); // backtrack

  if (fs.existsSync(root) === false) { // already done
    return rmdirSyncRecursive(root, chunks);
  }
  var err = fs.rmdirSync(root);
  return err ? err : rmdirSyncRecursive(pathname, chunks); // let's magic
}
function rmdirSyncRecursive ( root , chunks ) { var chunk = chunks . pop ( ) ; if ( ! chunk ) { return ; } var pathname = path . join ( root , '..' ) ; // backtrack if ( fs . existsSync ( root ) === false ) { // already done return rmdirSyncRecursive ( root , chunks ) ; } var err = fs . rmdirSync ( root ) ; return err ? err : rmdirSyncRecursive ( pathname , chunks ) ; // let's magic }
remove directory recursively. Sync version

@function rmdirRecursive
@param {String} root - absolute root where take chunks
@param {Array} chunks - directories chunks
@return [{Object}]
remove directory recursively . Sync version