<commit_before>/**
 * @description Checking file size.
 */

"use strict";

import 'babel-polyfill';
import fs from 'fs';
import clc from 'cli-color';
import filesize from 'filesize';

/**
 * @param {string} filePath - The file of the target.
 * @return {Promise}
 */
const getSize = (filePath) => {
  return new Promise((resolve, reject) => {
    fs.stat(filePath, (err, stats) => {
      if (err) {
        reject(err);
      }

      resolve(stats.size); // Byte
    });
  });
};

/**
 * @description Check file size and print message.
 * @param {string} filePath - The file of the target
 * @param {number} limitSize - Threshold for the file.
 */
const checkFileSize = async (filePath, limitSize) => {
  const fileSize         = await getSize(filePath);
  const readableFileSize = filesize(fileSize);

  if (Number(limitSize) < fileSize) {
    console.log(`[${clc.red('NG')}] ${filePath} ${fileSize}`);
    return;
  }

  console.log(`[${clc.green('OK')}] ${filePath} ${fileSize}`);<commit_msg>fix: use readable string for showing file size<commit_after>/**
 * @description Checking file size.
 */

"use strict";

import 'babel-polyfill';
import fs from 'fs';
import clc from 'cli-color';
import filesize from 'filesize';

/**
 * @param {string} filePath - The file of the target.
 * @return {Promise}
 */
const getSize = (filePath) => {
  return new Promise((resolve, reject) => {
    fs.stat(filePath, (err, stats) => {
      if (err) {
        reject(err);
      }

      resolve(stats.size); // Byte
    });
  });
};

/**
 * @description Check file size and print message.
 * @param {string} filePath - The file of the target
 * @param {number} limitSize - Threshold for the file.
 */
const checkFileSize = async (filePath, limitSize) => {
  const fileSize         = await getSize(filePath);
  const readableFileSize = filesize(fileSize);

  if (Number(limitSize) < fileSize) {
    console.log(`[${clc.red('NG')}] ${filePath} ${readableFileSize}`);
    return;
  }

  console.log(`[${clc.green('OK')}] ${filePath} ${readableFileSize}`);
{'fraction_non_alphanumeric': 0.16886930983847284, 'fraction_numerical': 0.0, 'mean_word_length': 3.4242424242424243, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1314347', 'n_tokens_mistral': 670, 'n_tokens_neox': 664, 'n_words': 186}