title: Export module after promise completes
body: <p>I actually want to put the "read" function in a different module and then require it in my main app.js. (I'm quite new to using promises)</p>
  
  <p>[REVISED]</p>
  
  <pre><code>var dir = require('node-dir');
  var files = function getFiles(){
  
          return new Promise(function (resolve, reject) {
          dir.files('../sample/sample', function (err, res){
              if (err) {
                      reject(err);
                      console.log('Oops, an error occured %s', err);
              }
              else {
                        resolve(res);
                        return res;
                    }
              });
          });
  }
  
  console.log(files);
  
  module.exports = files;
  </code></pre>
  
  <p>UPDATE AGAIN:</p>
  
  <pre><code>//read.js
  
  var dir = require('node-dir');
  var Promise = require('promise');
  
  
  module.exports = new Promise(function (resolve, reject) {
          dir.files('../sample/sample', function (error, results){
              if (error) {
                      reject(error);
                      console.log('Oops, an error occured %s', err);
              }
              else {
                        resolve(results);
                    }
              });
          })
  
  //app.js
  
  var filelist = require('./read');
  
  filelist.then(function (res){
  
      console.log(res);
  })
  </code></pre>
  
  <p>How do I go about that? I've tried "return new promise..." and putting the whole thing in a getFile function, but it doesn't return anything. </p>
  
  <p>What am I doing wrong?</p>