create-directory.js 312 B

12345678910111213
  1. const fs = require("fs/promises");
  2. const isAccessible = (pathFolder) => {
  3. return fs
  4. .access(pathFolder)
  5. .then(() => true)
  6. .catch(() => false);
  7. };
  8. const createFolderIsExist = async (folder) => {
  9. if (!(await isAccessible(folder))) await fs.mkdir(folder);
  10. };
  11. module.exports = createFolderIsExist;