"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.commandExecutor = commandExecutor;

var _path = require("path");

var _logger = require("../../logger");

var _spawnSyncIO = require("../../shared/commands-utils/spawnSyncIO");

var _constants = require("../../shared/constants");

function commandExecutor(options) {
  const {
    extraArgs
  } = options;
  const {
    enable,
    separateSeverPort,
    mockEntryFile,
    disableNodemon
  } = options.mockServer;

  if (!enable) {
    (0, _logger.messageLogger)('mock server not enabled');
    return;
  }

  if (!separateSeverPort) {
    (0, _logger.messageLogger)('mock server not port enabled');
    return;
  }

  const absolutePath = (0, _path.join)(__dirname, '..', '..', 'shared', 'server', 'mockServer.js');
  const mockFile = (0, _constants.joinWithAppPath)(mockEntryFile);
  (0, _logger.verboseLogger)('Mock server is running path', absolutePath);
  (0, _logger.verboseLogger)('App mock server is path', mockFile);
  (0, _logger.messageLogger)('mock server is running.....');
  (0, _spawnSyncIO.spawnSyncIO)(disableNodemon ? 'node' : 'nodemon', [absolutePath, '--watch', (0, _path.dirname)(mockFile), ...extraArgs]); // webpackBuild(options);
}