<commit_before>/**
 * Created by Ely on 10/4/2014.
 */
require("sjljs");

var fs = require('fs'),
    path = require('path'),
    yaml = require('js-yaml'),
    Bundle = require("./../src/Bundle.js"),
    exec = require('child_process').exec,
    log = function () {
        var args = sjl.argsToArray(arguments),
            verbose = sjl.extractBoolFromArrayEnd(args);
        if (verbose) {
            console.log.apply(console, args);
        }
    },

    throwBundleFileNotExistError = function (bundleName, filePath) {
        throw Error('Bundle "' + bundleName + '" config file doesn\'t exist.  Path checked: ' + filePath);
    };

module.exports = sjl.Extendable.extend(function Wrangler(gulp, argv, env, config) {
        var defaultOptions = yaml.safeLoad(fs.readFileSync(
                path.join(__dirname, "/../configs/default.wrangler.config.yaml"))),
            taskProxyMap = yaml.safeLoad(fs.readFileSync(
                path.join(__dirname, "/../configs/default.task.proxy.map.yaml")));

        log(argv, true);

        sjl.extend(true, this, {
            bundles: {},
            cwd: env.configBase,
            argv: argv,
            taskProxyMap: taskProxyMap,
            taskStrSeparator: ":",
            tasks: {}
        }, defaultOptions, config);

        // Resolve bundles path
        this.bundlesPath = path.join(this.cwd, this.bundlesPath);
        this.init(gulp, this.argv);
    },

    {
        init: function (gulp, argv) {
            log("Gulp Bundle Wrangler initializing...", argv.verbose);

            // Check if we have any global tasks to run
            var anyGlobalTasksToRun = argv.all || (argv._.filter(function (item) {
                return item.indexOf(':') === -1;
            })).length > 0;

            // Create task proxies (@todo in the future only load needed tasks if it makes any difference in performance)
            this.createTaskProxies(gulp);

            // If any global tasks to run create tasks proxies and register all bundles.
            if (anyGlobalTasksToRun) {
                this.createBundles(gulp);
            }

            // No global tasks to run (tasks on all modules) so register only passed in bundle(s)
            else {
                this.createBundles(gulp, this.extractBundlePathsFromArgv(this.argv));
            }

            // Run tasks
            exec('1 + 1', function (err, stdOut, stdError)


            return gulp;
        },

        createTaskProxies: function (gulp) {
            // Creating task proxies message
            log("- Creating task proxies.", this.argv.verbose);
            var self = this;
            Object.keys(self.tasks).forEach(function (task) {
                self.tasks[task].instance = self.createTaskProxy(gulp, task);
            });
            return self;
        },

        createTaskProxy: function (gulp, task) {
            // "Creating task ..." message
            log("Creating task proxy \"" + task + "\".  constructor at: \"" +
            this.taskProxyMap[task].constructorLocation + "\"", this.argv.verbose);
<commit_msg>Added a temporary execute action to Wrangler's init method.<commit_after>/**
 * Created by Ely on 10/4/2014.
 */
require("sjljs");

var fs = require('fs'),
    path = require('path'),
    yaml = require('js-yaml'),
    Bundle = require("./../src/Bundle.js"),
    exec = require('child_process').exec,
    log = function () {
        var args = sjl.argsToArray(arguments),
            verbose = sjl.extractBoolFromArrayEnd(args);
        if (verbose) {
            console.log.apply(console, args);
        }
    },

    throwBundleFileNotExistError = function (bundleName, filePath) {
        throw Error('Bundle "' + bundleName + '" config file doesn\'t exist.  Path checked: ' + filePath);
    };

module.exports = sjl.Extendable.extend(function Wrangler(gulp, argv, env, config) {
        var defaultOptions = yaml.safeLoad(fs.readFileSync(
                path.join(__dirname, "/../configs/default.wrangler.config.yaml"))),
            taskProxyMap = yaml.safeLoad(fs.readFileSync(
                path.join(__dirname, "/../configs/default.task.proxy.map.yaml")));

        log(argv, true);

        sjl.extend(true, this, {
            bundles: {},
            cwd: env.configBase,
            argv: argv,
            taskProxyMap: taskProxyMap,
            taskStrSeparator: ":",
            tasks: {}
        }, defaultOptions, config);

        // Resolve bundles path
        this.bundlesPath = path.join(this.cwd, this.bundlesPath);
        this.init(gulp, this.argv);
    },

    {
        init: function (gulp, argv) {
            log("Gulp Bundle Wrangler initializing...", argv.verbose);

            // Check if we have any global tasks to run
            var anyGlobalTasksToRun = argv.all || (argv._.filter(function (item) {
                return item.indexOf(':') === -1;
            })).length > 0;

            // Create task proxies (@todo in the future only load needed tasks if it makes any difference in performance)
            this.createTaskProxies(gulp);

            // If any global tasks to run create tasks proxies and register all bundles.
            if (anyGlobalTasksToRun) {
                this.createBundles(gulp);
            }

            // No global tasks to run (tasks on all modules) so register only passed in bundle(s)
            else {
                this.createBundles(gulp, this.extractBundlePathsFromArgv(this.argv));
            }

            // Run tasks
            exec('gulp ' + this.argv._.join(' '), function (error, stdout, stderr) {
                console.log('stdout: ' + stdout);
                console.log('stderr: ' + stderr);
                if (error !== null) {
                    console.log('exec error: ' + error);
                }
            });

            //log(gulp.__proto__, true);

            return gulp;
        },

        createTaskProxies: function (gulp) {
            // Creating task proxies message
            log("- Creating task proxies.", this.argv.verbose);
            var self = this;
            Object.keys(self.tasks).forEach(function (task) {
                self.tasks[task].instance = self.createTaskProxy(gulp, task);
            });
            return self;
        },

        createTaskProxy: function (gulp, task) {
            // "Creating task ..." message
            log("Creating task proxy \"" + task + "\".  constructor at: \"" +
            this.taskProxyMap[task].constructorLocation + "\"", this.argv.verbose);

{'fraction_non_alphanumeric': 0.12875076546233924, 'fraction_numerical': 0.003061849357011635, 'mean_word_length': 1.8528384279475982, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '4762512', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1779, 'n_words': 438}