<commit_before>/**
 * Copyright (c) 2015-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.
 */
'use strict';

var babel = require('babel-core');
var Transforms = require('../transforms');

// Runs internal transforms on the given sourceCode. Note that internal
// transforms should be run after the external ones to ensure that they run on
// Javascript code
function internalTransforms(sourceCode, filename, options) {
  var result = babel.transform(sourceCode, {
    retainLines: true,
    compact: true,
    comments: false,
    filename: filename,
    sourceFileName: filename,
    sourceMaps: false,
    plugins: Transforms.getAll(options)
  });

  return {
    code: result.code,
    filename: filename,
  };
}

function onExternalTransformDone(data, callback, error, externalOutput) {
  if (error) {
    callback(error);
    return;
  }

  var result = internalTransforms(
    externalOutput.code,
    externalOutput.filename,
    data.options
  );

  callback(null, result);
}

module.exports = function(data, callback) {
  try {
    if (data.options.externalTransformModulePath) {
      var externalTransformModule = require(
        data.options.externalTransformModulePath<commit_msg>Bail internal transforms if there're no transforms to run<commit_after>/**
 * Copyright (c) 2015-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.
 */
'use strict';

var babel = require('babel-core');
var Transforms = require('../transforms');

// Runs internal transforms on the given sourceCode. Note that internal
// transforms should be run after the external ones to ensure that they run on
// Javascript code
function internalTransforms(sourceCode, filename, options) {
  var plugins = Transforms.getAll(options);
  if (plugins.length === 0) {
    return {
      code: sourceCode,
      filename: filename,
    };
  }

  var result = babel.transform(sourceCode, {
    retainLines: true,
    compact: true,
    comments: false,
    filename: filename,
    sourceFileName: filename,
    sourceMaps: false,
    plugins: plugins,
  });

  return {
    code: result.code,
    filename: filename,
  };
}

function onExternalTransformDone(data, callback, error, externalOutput) {
  if (error) {
    callback(error);
    return;
  }

  var result = internalTransforms(
    externalOutput.code,
    externalOutput.filename,
    data.options
  );

  callback(null, result);
}

module.exports = function(data, callback) {
  try {
    if (data.options.externalTransformModulePath) {
      var externalTransformModule = require(
        data.options.externalTransformModulePath
{'fraction_non_alphanumeric': 0.09361561362884552, 'fraction_numerical': 0.0029771749917300696, 'mean_word_length': 3.595744680851064, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3828301', 'n_tokens_mistral': 849, 'n_tokens_neox': 817, 'n_words': 288}