'use strict';

const path = require('path');
const execa = require('execa');

const tools = require('../../scripts/utils/tools');
const configUtils = require('../../scripts/csdr/config/config-utils');

const defaultProject = configUtils.projects.getProject();

Promise.resolve()
  .then(() => {
    tools.logTitle(`Launching mock server : ${defaultProject.name}...`);
  })
  .then(() => {
    return tools.runScript(`nodemon --ext js --watch ./${defaultProject.folder}/mock/json ./${defaultProject.folder}/mock/json/server.js`);
  })
  .catch((e) => {
    tools.logError('ERROR during execution, see below');
    console.error(e);
    process.exit(1);
  });
