Skip to content

Commit

Permalink
Added promisified exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjoelkemp committed Mar 17, 2014
1 parent 0b93d86 commit 3225202
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions helpers/Utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
// Collection of little utility helpers
var fs = require('fs'),
q = require('q');

// Helper to return a slash-trailed version of the directory name
module.exports.slashDir = function (directory) {
return directory[directory.length - 1] === '/' ? directory : directory + '/';
};

// Promisified version of fs.exists
module.exports.exists = function (path) {
var deferred = q.defer();

fs.exists(path, function (exists) {
deferred.resolve(exists);
});

return deferred.promise;
};

0 comments on commit 3225202

Please sign in to comment.