<commit_before>import { transform } from 'babel-core';
import resolveRc from 'babel-core/lib/babel/tools/resolve-rc';
import * as babelUtil from 'babel-core/lib/babel/util';
import glob from 'glob';
import fs from 'fs';
import path from 'path';
import outputFileSync from 'output-file-sync';

export function buildContent(content, filename, destination, babelOptions={}) {
  const result = transform(content, resolveRc(filename, babelOptions));
  outputFileSync(destination, result.code, {encoding: 'utf8'});
}

export function buildFile(filename, destination, babelOptions={}) {
  let content = fs.readFileSync(filename, {encoding: 'utf8'});
  if (babelOptions.__reactBootstrapDeprecationWarning) {
    content = `console.warn('This file is deprecated, and will be removed in v0.24.0. Use react-bootstrap.js or react-bootstrap.min.js instead.');
console.warn('You can read more about it at https://github.com/react-bootstrap/react-bootstrap/issues/693');
${content}`;
  }

  if(babelUtil.canCompile(filename)) {
    // Get file basename without the extension (in case not .js)
    let outputName = path.basename(filename, path.extname(filename));
    // append the file basename with extension .js
    let outputPath = path.join(destination, outputName + '.js');
    // console.log('%s => %s', filename, outputPath);
    buildContent(content, filename, outputPath, babelOptions);
  }
}

export function buildFolder(folderPath, destination, babelOptions={}, firstFolder=true) {
  let stats = fs.statSync(folderPath);

  if(stats.isFile()) {
    buildFile(folderPath, destination, babelOptions);
  } else if(stats.isDirectory()) {
    let outputPath = firstFolder ? destination : path.join(destination, path.basename(folderPath));<commit_msg>Remove links to babel internal api and only use what we really need.<commit_after>import { transform } from 'babel-core';
import glob from 'glob';
import fs from 'fs';
import path from 'path';
import outputFileSync from 'output-file-sync';

export function buildContent(content, filename, destination, babelOptions={}) {
  babelOptions.filename = filename;
  const result = transform(content, babelOptions);
  outputFileSync(destination, result.code, {encoding: 'utf8'});
}

export function buildFile(filename, destination, babelOptions={}) {
  let content = fs.readFileSync(filename, {encoding: 'utf8'});
  if (babelOptions.__reactBootstrapDeprecationWarning) {
    content = `console.warn('This file is deprecated, and will be removed in v0.24.0. Use react-bootstrap.js or react-bootstrap.min.js instead.');
console.warn('You can read more about it at https://github.com/react-bootstrap/react-bootstrap/issues/693');
${content}`;
  }

  // We only have .js files that we need to build
  if(path.extname(filename) === '.js') {
    const outputPath = path.join(destination, path.basename(filename));
    // console.log('%s => %s', filename, outputPath);
    buildContent(content, filename, outputPath, babelOptions);
  }
}

export function buildFolder(folderPath, destination, babelOptions={}, firstFolder=true) {
  let stats = fs.statSync(folderPath);

  if(stats.isFile()) {
    buildFile(folderPath, destination, babelOptions);
  } else if(stats.isDirectory()) {
    let outputPath = firstFolder ? destination : path.join(destination, path.basename(folderPath));
{'fraction_non_alphanumeric': 0.13218390804597702, 'fraction_numerical': 0.0054446460980036296, 'mean_word_length': 5.192883895131086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '310330', 'n_tokens_mistral': 973, 'n_tokens_neox': 953, 'n_words': 266}