a zip code crypto-currency system good for red ONLY

ConcordMainPlugin.js 1.1KB

12345678910111213141516171819202122232425262728293031
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. var path = require("path");
  6. var concord = require("./concord");
  7. var DescriptionFileUtils = require("./DescriptionFileUtils");
  8. function ConcordMainPlugin(source, options, target) {
  9. this.source = source;
  10. this.options = options;
  11. this.target = target;
  12. }
  13. module.exports = ConcordMainPlugin;
  14. ConcordMainPlugin.prototype.apply = function(resolver) {
  15. var target = this.target;
  16. resolver.plugin(this.source, function(request, callback) {
  17. if(request.path !== request.descriptionFileRoot) return callback();
  18. var concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
  19. if(!concordField) return callback();
  20. var mainModule = concord.getMain(request.context, concordField);
  21. if(!mainModule) return callback();
  22. var obj = Object.assign({}, request, {
  23. request: mainModule
  24. });
  25. var filename = path.basename(request.descriptionFilePath);
  26. return resolver.doResolve(target, obj, "use " + mainModule + " from " + filename, callback);
  27. });
  28. };