Skip to content

Commit

Permalink
refactor: replace new Promise(resolve) 11ty#2
Browse files Browse the repository at this point in the history
  • Loading branch information
franktip committed Aug 24, 2021
1 parent 2eec6fc commit 8adfbf4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/TemplatePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,20 @@ TemplatePath.isDirectorySync = function (path) {
* @returns {Boolean} whether `path` points to an existing directory.
*/
TemplatePath.isDirectory = async function (path) {
return new Promise((resolve) => {
fs.stat(path, (err, stats) => {
if (stats) {
resolve(stats.isDirectory());
}
resolve(false);
});
});
console.log("*** EXECUTING src/TemplatePath.js:258:265");
// return new Promise((resolve) => {
// fs.stat(path, (err, stats) => {
// if (stats) {
// resolve(stats.isDirectory());
// }
// resolve(false);
// });
// });

return fs.promises
.stat(path)
.then((stats) => stats.isDirectory())
.catch(() => false);
};

/**
Expand Down

0 comments on commit 8adfbf4

Please sign in to comment.