<commit_before>#!/usr/bin/env babel-node

/**
 * This file is responsible for building Bacon.js, Bacon.noAssert.js and Bacon.min.js
 */

"use strict";

var _ = require("lodash");
var fs = require("fs");
var path = require("path");
var Deps = require("./build-deps");
var babel = require("babel");
var assert = require("assert");
var uglifyjs = require("uglify-js");
var esprima = require("esprima");
var estraverse = require("estraverse");
var escodegen = require("escodegen");
var jsstana = require("jsstana");

var argPieceNames =  process.argv.slice(2)
var manifests = argPieceNames.length ? argPieceNames : ["main"];
var defaultOutput = path.join(__dirname, "dist", "Bacon.js");
var defaultNoAssert = path.join(__dirname, "dist", "Bacon.noAssert.js");
var defaultMinified = path.join(__dirname, "dist", "Bacon.min.js");

// Boilerplate: *header* and *footer*
var header = fs.readFileSync(path.join(__dirname, "src", "boilerplate",  "object.js"), "utf-8");
var footer = fs.readFileSync(path.join(__dirname, "src", "boilerplate",  "exports.js"), "utf-8");
// 16 spaces
var padding = "                ";

var main = function(options){
  options = options || {};

  var pieces = Deps.resolvePieces(manifests, "src");

  if (options.verbose) {
    console.info("Linearised dependency graph:")
    _.each(pieces, function (p) {
      var name = p.name + (p.type === "js" ? "*" : "");
      if (p.deps.length === 0) {
        console.info(" ", name);
      } else {
        console.info(" ", name + padding.substr(name.length), "←", p.deps.join(", "));
      }
    });
  }

  // let's be conservative with Babel options:
  var babelOptions = {
    comments: false,
    whitelist: [
      "es3.memberExpressionLiterals",
      "es3.propertyLiterals",
      "es6.arrowFunctions",
      "es6.blockScoping",
      "es6.properties.shorthand",
      "es6.constants",
      "es6.destructuring",
      "es6.parameters",
      "es6.spread"
    ]
  };

  var esOutput = header + _.pluck(pieces, "contents").join("\n") + footer;
  var esTranspiled = babel.transform(esOutput, babelOptions);
  var output = esTranspiled.code;

  // Stripping asserts
  function notAssertStatement(node) {<commit_msg>Wrap generated JS with IIFE<commit_after>#!/usr/bin/env babel-node

/**
 * This file is responsible for building Bacon.js, Bacon.noAssert.js and Bacon.min.js
 */

"use strict";

var _ = require("lodash");
var fs = require("fs");
var path = require("path");
var Deps = require("./build-deps");
var babel = require("babel");
var assert = require("assert");
var uglifyjs = require("uglify-js");
var esprima = require("esprima");
var estraverse = require("estraverse");
var escodegen = require("escodegen");
var jsstana = require("jsstana");

var argPieceNames =  process.argv.slice(2)
var manifests = argPieceNames.length ? argPieceNames : ["main"];
var defaultOutput = path.join(__dirname, "dist", "Bacon.js");
var defaultNoAssert = path.join(__dirname, "dist", "Bacon.noAssert.js");
var defaultMinified = path.join(__dirname, "dist", "Bacon.min.js");

// Boilerplate: *header* and *footer*
var header = fs.readFileSync(path.join(__dirname, "src", "boilerplate",  "object.js"), "utf-8");
var footer = fs.readFileSync(path.join(__dirname, "src", "boilerplate",  "exports.js"), "utf-8");
// 16 spaces
var padding = "                ";

var main = function(options){
  options = options || {};

  var pieces = Deps.resolvePieces(manifests, "src");

  if (options.verbose) {
    console.info("Linearised dependency graph:")
    _.each(pieces, function (p) {
      var name = p.name + (p.type === "js" ? "*" : "");
      if (p.deps.length === 0) {
        console.info(" ", name);
      } else {
        console.info(" ", name + padding.substr(name.length), "←", p.deps.join(", "));
      }
    });
  }

  // let's be conservative with Babel options:
  var babelOptions = {
    comments: false,
    whitelist: [
      "es3.memberExpressionLiterals",
      "es3.propertyLiterals",
      "es6.arrowFunctions",
      "es6.blockScoping",
      "es6.properties.shorthand",
      "es6.constants",
      "es6.destructuring",
      "es6.parameters",
      "es6.spread"
    ]
  };

  var esOutput = header + _.pluck(pieces, "contents").join("\n") + footer;
  var esTranspiled = babel.transform(esOutput, babelOptions);
  var output = "(function() {\n" + esTranspiled.code + "\n}).call(this);";

  // Stripping asserts
  function notAssertStatement(node) {
{'fraction_non_alphanumeric': 0.17635089305900972, 'fraction_numerical': 0.006782726656115758, 'mean_word_length': 3.6324607329842933, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6455135', 'n_tokens_mistral': 1523, 'n_tokens_neox': 1472, 'n_words': 329}