title: Can I make node.js FTP synchronous?
body: <p>I have a little FTP script which basically transfer an entire directory tree (by walking it with <code>fs.readdir</code>) to an FTP server one file at a time (I have to do some analysis on each file as it's uploaded hence the one-at-a-time behaviour).</p>
  
  <p>However, the bit that does a single file (there's another bit for directories which uses <code>c.mkdir</code> rather than <code>c.put</code>) looks like this:</p>
  
  <pre><code>console.log('Transferring [' + ival + ']');
  var c = new Ftp();
  c.on('ready', function() {
      c.put(ival, ival, function(err) {
          console.log(err);
      });
      c.end();
  });
  </code></pre>
  
  <p>As you can see, it's using a very simple method of logging in that failures simply get sent to the console.</p>
  
  <p>Unfortunately, since the FTPs are done asynchronously, errors are being delivered to the console in a sequence totally unrelated to the file name output.</p>
  
  <p>Is there a way to force the FTP to be done synchronously so that errors would immediately follow the file name? Basically, I want the entire sequence from the initial <code>console.log</code> to the final <code>});</code> to be done before moving on to the next file.</p>