<commit_before>/*global require*/

const chalk   = require('chalk');
const Table   = require('cli-table2');         // INFO: https://www.npmjs.com/package/cli-table2
const fs      = require('fs');

function buildMenu(pkgInfo = {}, opts = {}) {

  console.log(opts);

  if (!pkgInfo.hasOwnProperty('scripts')) {
    return {error: true, message: 'package.json does not contain any scripts'};
  }

  let table;

  // instantiate
  if(opts.compress) {
		table = new Table({
			head: ['Name']
		});
  }
  else {
		table = new Table({
			head: ['Name', 'Script'],
			colWidths: [20]
		});
  }


  const scripts     = pkgInfo.scripts;
  const scriptNames = Object.keys(scripts);

  if (opts.sort) {
    scriptNames.sort();
  }
  if(!opts.compress) {
      scriptNames.map((item) => {
        table.push(
        [item, scripts[item]]
      );
    });
  } else {
		scriptNames.map((item) => {
			table.push([item]);
    });
  }

  return table;
}

function printMenu(filename = '', options = {}) {
  const pkgInfo = getPackageInfo(filename);
  if (pkgInfo.hasOwnProperty('error')) {
    console.log(chalk.red(pkgInfo.msg));
    return pkgInfo;<commit_msg>code update<commit_after>/*global require*/

const chalk   = require('chalk');
const Table   = require('cli-table2');         // INFO: https://www.npmjs.com/package/cli-table2
const fs      = require('fs');

function buildMenu(pkgInfo = {}, opts = {}) {

  console.log(opts);

  if (!pkgInfo.hasOwnProperty('scripts')) {
    return {error: true, message: 'package.json does not contain any scripts'};
  }

  let table;

  // instantiate
  if (opts.compress) {
		table = new Table({
			head: ['Name']
		});
  }
  else {
		table = new Table({
			head: ['Name', 'Script'],
			colWidths: [20]
		});
  }


  const scripts     = pkgInfo.scripts;
  const scriptNames = Object.keys(scripts);

  if (opts.sort) {
    scriptNames.sort();
  }
  if (!opts.compress) {
      scriptNames.map((item) => {
        table.push(
        [item, scripts[item]]
      );
    });
  }
  else {
		scriptNames.map((item) => {
			table.push([item]);
    });
  }

  return table;
}

function printMenu(filename = '', options = {}) {
  const pkgInfo = getPackageInfo(filename);
  if (pkgInfo.hasOwnProperty('error')) {
    console.log(chalk.red(pkgInfo.msg));
    return pkgInfo;
{'fraction_non_alphanumeric': 0.17580504786771106, 'fraction_numerical': 0.0034812880765883376, 'mean_word_length': 2.8703703703703702, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5857121', 'n_tokens_mistral': 814, 'n_tokens_neox': 762, 'n_words': 156}