You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
775 B

4 years ago
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const Hook = require("./Hook");
  7. const HookCodeFactory = require("./HookCodeFactory");
  8. class SyncHookCodeFactory extends HookCodeFactory {
  9. content({ onError, onDone, rethrowIfPossible }) {
  10. return this.callTapsSeries({
  11. onError: (i, err) => onError(err),
  12. onDone,
  13. rethrowIfPossible
  14. });
  15. }
  16. }
  17. const factory = new SyncHookCodeFactory();
  18. class SyncHook extends Hook {
  19. tapAsync() {
  20. throw new Error("tapAsync is not supported on a SyncHook");
  21. }
  22. tapPromise() {
  23. throw new Error("tapPromise is not supported on a SyncHook");
  24. }
  25. compile(options) {
  26. factory.setup(this, options);
  27. return factory.create(options);
  28. }
  29. }
  30. module.exports = SyncHook;