Here's a function that I use. Nobody is making use of promisify
and await/async
feature in this post so I thought I would share.
const promisify = require('util').promisify;
const lstat = promisify(require('fs').lstat);
async function isDirectory (path) {
try {
return (await lstat(path)).isDirectory();
}
catch (e) {
return false;
}
}
Note : I don't use require('fs').promises;
because it has been experimental for one year now, better not rely on it.