a zip code crypto-currency system good for red ONLY

ModuleAppendPlugin.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. function ModuleAppendPlugin(source, appending, target) {
  6. this.source = source;
  7. this.appending = appending;
  8. this.target = target;
  9. }
  10. module.exports = ModuleAppendPlugin;
  11. ModuleAppendPlugin.prototype.apply = function(resolver) {
  12. var appending = this.appending;
  13. var target = this.target;
  14. resolver.plugin(this.source, function(request, callback) {
  15. var i = request.request.indexOf("/"),
  16. j = request.request.indexOf("\\");
  17. var p = i < 0 ? j : j < 0 ? i : i < j ? i : j;
  18. var moduleName, remainingRequest;
  19. if(p < 0) {
  20. moduleName = request.request;
  21. remainingRequest = "";
  22. } else {
  23. moduleName = request.request.substr(0, p);
  24. remainingRequest = request.request.substr(p);
  25. }
  26. if(moduleName === "." || moduleName === "..")
  27. return callback();
  28. var moduleFinalName = moduleName + appending;
  29. var obj = Object.assign({}, request, {
  30. request: moduleFinalName + remainingRequest
  31. });
  32. resolver.doResolve(target, obj, "module variation " + moduleFinalName, callback);
  33. });
  34. };