<commit_before>module.exports = function (grunt) {
    var rollup = require('rollup'),
        path = require('path'),
        dirs = grunt.config('dirs'),
        files = grunt.config('files'),
        version = {
            es5: 'es5',
            es6: 'es6'
        };


    // transpile es6 modules
    function transpile(ver) {
        return rollup.rollup({
            entry: path.join(dirs.source, ver, files.main)
        }).then(function (bundle) {
            return bundle.write({
                // output format - 'amd', 'cjs', 'es6', 'iife', 'umd'
                format: 'umd',
                dest: path.join(dirs.build, ver, files.main),
                sourceMap: false,
                banner: grunt.config('banner'),
                outro: 'mx.version = \'' + grunt.config('pkg').version + '\';\n',
                footer: ' ',
                moduleName: 'mx'
            });
        });
    }

    // transpile unit tests
    function transpileTests(ver) {
        var files = grunt.file.expand({ cwd: dirs.test }, '**/*.js'),
            header = grunt.file.read(dirs.test + '/test-header');

        return Promise.all(files.map(function (file) {
            return rollup.rollup({
                entry: path.join(dirs.test, file)
            }).then(function (bundle) {
                var code = header + bundle.generate({
                    // output format - 'amd', 'cjs', 'es6', 'iife', 'umd'
                    format: 'iife',
                    sourceMap: false,
                    useStrict: false
                }).code.split('\n').slice(1).join('\n');

                grunt.file.write(path.join(dirs.build, ver, 'test', file), code);
            });
        }));
    }

    grunt.task.registerTask('transpile-code', 'builds all files/tests, compiles es6 modules', function () {
        var done = this.async();

        Promise.resolve(null)
            .then(function () {
                return transpile(version.es5);
            })
            .then(function () {
                grunt.log.ok('transpile es5');
            })
            .then(function () {
                return transpileTests(version.es5);
            })
            .then(function () {
                grunt.log.ok('transpile es5 tests');
            })
            .then(function () {
                return transpile(version.es6);
            })
            .then(function () {
                grunt.log.ok('transpile es6');
            })
            .then(function () {
                return transpileTests(version.es6);
            })
            .then(function () {
                grunt.log.ok('transpile es6 tests');
            })
            .then(done, function (e) {
                grunt.log.error('error transpiling', e);
                done(e);
            });
    });


    grunt.task.registerTask('transpile', 'cleans build directory, builds all files, compiles es6 modules', function () {
        var tasks = [
            'clean:build',
            'transpile-code'
        ];
        grunt.task.run(tasks);
    });
};
<commit_msg>init transpile<commit_after>module.exports = function (grunt) {
    var rollup = require('rollup'),
        path = require('path'),
        dirs = grunt.config('dirs'),
        files = grunt.config('files');


    // transpile es6 modules
    function transpile() {
        return rollup.rollup({
            entry: path.join(dirs.source, files.main)
        }).then(function (bundle) {
            return bundle.write({
                // output format - 'amd', 'cjs', 'es6', 'iife', 'umd'
                format: 'umd',
                dest: path.join(dirs.build, files.main),
                sourceMap: false,
                banner: grunt.config('banner'),
                outro: 'mx.version = \'' + grunt.config('pkg').version + '\';\n',
                footer: '\n',
                moduleName: 'mx'
            });
        });
    }

    // transpile unit tests
    function transpileTests() {
        var files = grunt.file.expand({ cwd: dirs.test }, '**/*.js'),
            header = grunt.file.read(dirs.test + '/test-header');

        return Promise.all(files.map(function (file) {
            return rollup.rollup({
                entry: path.join(dirs.test, file)
            }).then(function (bundle) {
                var code = header + bundle.generate({
                    // output format - 'amd', 'cjs', 'es6', 'iife', 'umd'
                    format: 'umd',
                    footer: '\n',
                    sourceMap: false,
                    useStrict: false
                }).code.split('\n').slice(5).join('\n');

                grunt.file.write(path.join(dirs.build, 'test', file), code);
            });
        }));
    }

    grunt.task.registerTask('transpile-code', 'builds all files/tests, compiles es6 modules', function () {
        var done = this.async();

        Promise.resolve(null)
            .then(function () {
                return transpile();
            })
            .then(function () {
                grunt.log.ok('transpile code');
            })
            .then(function () {
                return transpileTests();
            })
            .then(function () {
                grunt.log.ok('transpile tests');
            })
            .then(done, function (e) {
                grunt.log.error('error transpiling', e);
                done(e);
            });
    });


    grunt.task.registerTask('transpile', 'cleans build directory, builds all files, compiles es6 modules', function () {
        var tasks = [
            'clean:build',
            'transpile-code'
        ];
        grunt.task.run(tasks);
    });
};

{'fraction_non_alphanumeric': 0.1504237288135593, 'fraction_numerical': 0.00423728813559322, 'mean_word_length': 1.4044991511035654, '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': '2926885', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1571, 'n_words': 310}