Today's npm package: is-directory
I am developer from India currently based in Berlin, Germany.
I am very interested in Design, though I don't design ๐ I take care of it while making my apps.
Photography, videography and having random conversation over beer are my activities of spare time. Timelapses and hyperlapses make me wonder all the time ๐
Today's npm package is is-directory
This package will help you check if the supplied path is a directory or not. It will return true if the file path exists on the file system and its directory.
const fs = require('fs');
const isDirectory = require('is-directory');
isDirectory('dist', function(err, dir) {
if (err) { // directory doesn't exist or isn't a directory
fs.mkdirSync('dist') // make the directory
}
console.log(dir);
//=> true
});
Or synchronized version as:
const fs = require('fs');
const isDirectory = require('is-directory');
if (!isDirectory.sync('dist')) { // if directory doesn't exist
fs.mkdirSync('dist') // make the directory
}




