a zip code crypto-currency system good for red ONLY

FileExistsPlugin.js 927B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. function FileExistsPlugin(source, target) {
  6. this.source = source;
  7. this.target = target;
  8. }
  9. module.exports = FileExistsPlugin;
  10. FileExistsPlugin.prototype.apply = function(resolver) {
  11. var target = this.target;
  12. resolver.plugin(this.source, function(request, callback) {
  13. var fs = this.fileSystem;
  14. var file = request.path;
  15. fs.stat(file, function(err, stat) {
  16. if(err || !stat) {
  17. if(callback.missing) callback.missing.push(file);
  18. if(callback.log) callback.log(file + " doesn't exist");
  19. return callback();
  20. }
  21. if(!stat.isFile()) {
  22. if(callback.missing) callback.missing.push(file);
  23. if(callback.log) callback.log(file + " is not a file");
  24. return callback();
  25. }
  26. this.doResolve(target, request, "existing file: " + file, callback, true);
  27. }.bind(this));
  28. });
  29. };