<commit_before>/**
 * Copyright (c) 2016-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @flow
 */

import BaseReporter from "../_base.js";
import Progress from "./progress-bar.js";
import Spinner from "./spinner.js";
import type { Package, Trees } from "../types.js";
import { clearLine } from "./util.js";
import { removeSuffix } from "../../util/misc.js";

let readline = require("readline");
let repeat   = require("repeating");
let chalk    = require("chalk");
let _        = require("lodash");

function sortTrees(trees: Trees = []): Trees {
  return trees.sort((tree1, tree2) => {
    return tree1.name.localeCompare(tree2.name);
  });
}

export default class ConsoleReporter extends BaseReporter {
  _prependEmoji(msg: string, emoji: ?string): string {
    if (this.emoji && emoji && this.isTTY) msg = `${emoji}  ${msg}`;
    return msg;
  }

  step(current: number, total: number, msg: string, emoji?: string) {
    msg = `${this._prependEmoji(msg, emoji)}...`;
    if (_.endsWith(msg, "?...")) {
      msg = `${removeSuffix(msg, "?...")}...?`;
    }
    this.log(`${chalk.grey(`[${current}/${total}]`)} ${msg}`);<commit_msg>clean up ConsoleReporter.step question<commit_after>/**
 * Copyright (c) 2016-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @flow
 */

import BaseReporter from "../_base.js";
import Progress from "./progress-bar.js";
import Spinner from "./spinner.js";
import type { Package, Trees } from "../types.js";
import { clearLine } from "./util.js";
import { removeSuffix } from "../../util/misc.js";

let readline = require("readline");
let repeat   = require("repeating");
let chalk    = require("chalk");
let _        = require("lodash");

function sortTrees(trees: Trees = []): Trees {
  return trees.sort((tree1, tree2) => {
    return tree1.name.localeCompare(tree2.name);
  });
}

export default class ConsoleReporter extends BaseReporter {
  _prependEmoji(msg: string, emoji: ?string): string {
    if (this.emoji && emoji && this.isTTY) msg = `${emoji}  ${msg}`;
    return msg;
  }

  step(current: number, total: number, msg: string, emoji?: string) {
    msg = this._prependEmoji(msg, emoji);

    if (_.endsWith(msg, "?")) {
      msg = `${removeSuffix(msg, "?")}...?`;
    } else {
      msg += "...";
    }

    this.log(`${chalk.grey(`[${current}/${total}]`)} ${msg}`);
{'fraction_non_alphanumeric': 0.1725251076040172, 'fraction_numerical': 0.005738880918220947, 'mean_word_length': 3.534959349593496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3805802', 'n_tokens_mistral': 910, 'n_tokens_neox': 906, 'n_words': 268}