code: function isValidDir(dir) {
      var fs = require("fs");
      try {
          return fs.statSync(dir).isDirectory();
      } catch (err) {
          return false;
      }
  }
docs: Validate directory exists
  usage:
  dir - String path of directory to check