<commit_before>'use strict';
const patternlab = require('@pattern-lab/core');
const _ = require('lodash');

const isValidConfig = require('./validate-config');
const { error, info } = require('./utils');

/**
 * @func serve
 * @desc Start a browser-sync server in the Pattern Lab public dir
 * @param {object} config - The passed Pattern Lab config
 */
function serve(config) {
  if (!isValidConfig) {
    throw new TypeError(
      'serve: Expects config not to be empty and of type object.'
    );
  }

  if (
    !_.has(config, 'paths.public.root') ||
    _.isEmpty(config.paths.public.root)
  ) {
    throw new TypeError(
      'serve: config.paths.public.root is empty or does not exist. Please check your Pattern Lab config.'
    );
  }
  if (
    !_.has(config, 'paths.source.root') ||
    _.isEmpty(config.paths.source.root)
  ) {
    throw new TypeError(
      'serve: config.paths.source.root is empty or does not exist. Please check your Pattern Lab config.'
    );
  }

  try {
    info(`serve: Serving your files …`);
    const pl = patternlab(config);
    console.log(pl);
    pl.server.serve({});
  } catch (err) {
    console.log(err);
    error(err);
  }
}

module.exports = serve;
<commit_msg>chore(cli): remove console statements<commit_after>'use strict';
const patternlab = require('@pattern-lab/core');
const _ = require('lodash');

const isValidConfig = require('./validate-config');
const { error, info } = require('./utils');

/**
 * @func serve
 * @desc Start a browser-sync server in the Pattern Lab public dir
 * @param {object} config - The passed Pattern Lab config
 */
function serve(config) {
  if (!isValidConfig) {
    throw new TypeError(
      'serve: Expects config not to be empty and of type object.'
    );
  }

  if (
    !_.has(config, 'paths.public.root') ||
    _.isEmpty(config.paths.public.root)
  ) {
    throw new TypeError(
      'serve: config.paths.public.root is empty or does not exist. Please check your Pattern Lab config.'
    );
  }
  if (
    !_.has(config, 'paths.source.root') ||
    _.isEmpty(config.paths.source.root)
  ) {
    throw new TypeError(
      'serve: config.paths.source.root is empty or does not exist. Please check your Pattern Lab config.'
    );
  }

  try {
    info(`serve: Serving your files …`);
    const pl = patternlab(config);
    pl.server.serve({});
  } catch (err) {
    error(err);
  }
}

module.exports = serve;

{'fraction_non_alphanumeric': 0.14273824386183936, 'fraction_numerical': 0.0, 'mean_word_length': 3.033557046979866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6168776', 'n_tokens_mistral': 748, 'n_tokens_neox': 745, 'n_words': 225}