No Description
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.

hostingEmulator.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.HostingEmulator = void 0;
  4. const serveHosting = require("../serve/hosting");
  5. const types_1 = require("../emulator/types");
  6. const constants_1 = require("./constants");
  7. class HostingEmulator {
  8. constructor(args) {
  9. this.args = args;
  10. }
  11. async start() {
  12. this.args.options.host = this.args.host;
  13. this.args.options.port = this.args.port;
  14. const { ports } = await serveHosting.start(this.args.options);
  15. this.args.port = ports[0];
  16. if (ports.length > 1) {
  17. this.reservedPorts = ports.slice(1);
  18. }
  19. }
  20. connect() {
  21. return Promise.resolve();
  22. }
  23. stop() {
  24. return serveHosting.stop();
  25. }
  26. getInfo() {
  27. const host = this.args.host || constants_1.Constants.getDefaultHost();
  28. const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.HOSTING);
  29. return {
  30. name: this.getName(),
  31. host,
  32. port,
  33. reservedPorts: this.reservedPorts,
  34. };
  35. }
  36. getName() {
  37. return types_1.Emulators.HOSTING;
  38. }
  39. }
  40. exports.HostingEmulator = HostingEmulator;