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