diff --git a/lib/cows.js b/lib/cows.js index 8ebf14d..971ef41 100644 --- a/lib/cows.js +++ b/lib/cows.js @@ -32,10 +32,16 @@ exports.get = function (cow) { } exports.list = function (callback) { - fs.readdir(cowsPath, function (err, files) { - if (err) return callback(err); - - return callback(null, cowNamesFromFiles(files)); + return new Promise(function (resolve, reject) { + fs.readdir(cowsPath, function (err, files) { + if (err) { + reject(err); + callback(err); + } else { + resolve(files); + callback(null, cowNamesFromFiles(files)); + } + }); }); }