<commit_before>"use strict";

// This script rebuilds the lib/builtins-*.js files
// It is run before publishing to NPM.
// You must npm install babel and babel-plugin-streamline before running it.
var babel = require('babel-core');
require('babel-plugin-streamline');
var fs = require('fs');
var fsp = require('path');

function build(src, dst, runtime, fix) {
	var babelOptions = {
		plugins: ['streamline'],
		whitelist: [],
		extra: {
			streamline: {
				runtime: runtime,
				verbose: true,
			},
		},
	};
	if (runtime === 'callbacks') babelOptions.whitelist.push('regenerator');
	babelOptions.filename = src;
	babelOptions.sourceFileName = src;
	//babelOptions.sourceMaps = "inline";
	var source = fs.readFileSync(fsp.join(__dirname, 'src', src), 'utf8');
	var code =  babel.transform(source, babelOptions).code;
	if (fix) code = fix(code);
	fs.writeFileSync(fsp.join(__dirname, 'lib', dst), code, 'utf8');
}

['builtins', 'flows'].forEach(function(mod) {
	['callbacks', 'await', 'fibers', 'generators'].forEach(function(runtime) {
		build(mod + '._js', runtime + '/' + mod + '.js', runtime);
	});
})
build('../lib/generators/runtime.js', 'callbacks/runtime.js', 'callbacks', function(code) {
	return code.replace(/getGlobals\('generators'\)/g, "getGlobals('callbacks')");
});
<commit_msg>issue #2 - upgrade build script to babel 6<commit_after>"use strict";

// This script rebuilds the lib/builtins-*.js files
// It is run before publishing to NPM.
// You must npm install babel and babel-plugin-streamline before running it.
var babel = require('babel-core');
require('babel-plugin-streamline');
var fs = require('fs');
var fsp = require('path');

function build(src, dst, runtime, fix) {
	var es2015 = require('babel-preset-es2015');
	var regeneratorPlugin = es2015.plugins[es2015.plugins.length - 1];
 	if (runtime === 'generators') {
		regeneratorPlugin[1].generators = false;
	}
	var babelOptions = {
		plugins: [[require('babel-plugin-streamline'), {
			runtime: runtime,
			verbose: true,			
		}]],
		presets: es2015,
	};

	babelOptions.filename = src;
	babelOptions.sourceFileName = src;
	//babelOptions.sourceMaps = "inline";
	var source = fs.readFileSync(fsp.join(__dirname, 'src', src), 'utf8');
	var code =  babel.transform(source, babelOptions).code;
	if (fix) code = fix(code);
	fs.writeFileSync(fsp.join(__dirname, 'lib', dst), code, 'utf8');
}

['builtins', 'flows'].forEach(function(mod) {
	['callbacks', 'await', 'fibers', 'generators'].forEach(function(runtime) {
		build(mod + '._js', runtime + '/' + mod + '.js', runtime);
	});
})
build('../lib/generators/runtime.js', 'callbacks/runtime.js', 'callbacks', function(code) {
	return code.replace(/getGlobals\('generators'\)/g, "getGlobals('callbacks')");
});

{'fraction_non_alphanumeric': 0.18523931311655098, 'fraction_numerical': 0.010230179028132993, 'mean_word_length': 4.837953091684435, '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': '578009', 'n_tokens_mistral': 985, 'n_tokens_neox': 919, 'n_words': 212}