function readFilePromise(filename) {
  var deferred;

  deferred = Q.defer();

  fs.readFile(filename, 'utf-8', function (err, contents) {
    if (err) {
      if (err.code === 'ENOENT') {
        debug(err.code + ': ' + filename);
        return deferred.resolve();
      }
      debug(err + ' ' + filename);
      // TODO: better error handling
      deferred.reject(err);
    } else {
      debug('read ' + filename);
      deferred.resolve(contents);
    }
  });

  return deferred.promise;
}
function readFilePromise(filename) {
  var deferred;

  deferred = Q.defer();

  fs.readFile(filename, 'utf-8', function (err, contents) {
    if (err) {
      if (err.code === 'ENOENT') {
        debug(err.code + ': ' + filename);
        return deferred.resolve();
      }
      debug(err + ' ' + filename);
      
      deferred.reject(err);
    } else {
      debug('read ' + filename);
      deferred.resolve(contents);
    }
  });

  return deferred.promise;
}
function readFilePromise ( filename ) { var deferred ; deferred = Q . defer ( ) ; fs . readFile ( filename , 'utf-8' , function ( err , contents ) { if ( err ) { if ( err . code === 'ENOENT' ) { debug ( err . code + ': ' + filename ) ; return deferred . resolve ( ) ; } debug ( err + ' ' + filename ) ; // TODO: better error handling deferred . reject ( err ) ; } else { debug ( 'read ' + filename ) ; deferred . resolve ( contents ) ; } } ) ; return deferred . promise ; }
Promise to load a file's contents

@param {string} filename The file to load
@return {Promise.<string>} The file's contents
Promise to load a file s contents