lib/package.js
function like_a_boss(attempt) {
    fs.rename(from, to, function(err) {
      if (err) log('Error when moving directory: ' + err.message);

      // if no error, or err is not EPERM/EACCES, we're done
      if (!err || (err.code != 'EPERM' && err.code != 'EACCES'))
        cb();
      else if (attempt >= 30) // max attempts reached, so give up.
        cb(err);
      else
        setTimeout(function() { like_a_boss(attempt + 1) }, 1000);

    })
  }
function like_a_boss(attempt) {
    fs.rename(from, to, function(err) {
      if (err) log('Error when moving directory: ' + err.message);

      // if no error, or err is not EPERM/EACCES, we're done
      if (!err || (err.code != 'EPERM' && err.code != 'EACCES'))
        cb();
      else if (attempt >= 30) // max attempts reached, so give up.
        cb(err);
      else
        setTimeout(function() { like_a_boss(attempt + 1) }, 1000);

    })
  }
function like_a_boss ( attempt ) { fs . rename ( from , to , function ( err ) { if ( err ) log ( 'Error when moving directory: ' + err . message ) ; // if no error, or err is not EPERM/EACCES, we're done if ( ! err || ( err . code != 'EPERM' && err . code != 'EACCES' ) ) cb ( ) ; else if ( attempt >= 30 ) // max attempts reached, so give up. cb ( err ) ; else setTimeout ( function ( ) { like_a_boss ( attempt + 1 ) } , 1000 ) ; } ) }
on windows, antivirus softwares lock new folders until all files are scanned which causes a EPERM error when doing a fs.rename. to prevent this from ruining the process, we'll retry the fs.rename 10 times every one second if we do get a EPERM error.
on windows antivirus softwares lock new folders until all files are scanned which causes a EPERM error when doing a fs . rename . to prevent this from ruining the process we ll retry the fs . rename 10 times every one second if we do get a EPERM error .