<commit_before>(function(undefined) {
    'use strict';

    var ERROR_CONFIG_NOT_FOUND  = 2,
        ERROR_DEP_NOT_FOUND     = 3,
        JSON_SPACES             = 4,
        ENOENT                  = 'ENOENT',
        DEFAULT_BOWER_COMMAND   = 'help',
        DEFAULT_BOWER_DIR       = 'vendor',
        SRC_FILE                = '_source',
        GRUNT_FILE              = 'grunt.js',
        JETFUEL_FILE            = '.jetfuel.json',
        BOWER_LATEST            = '*';

    var util = require('util'),
        fs = require('fs'),
        path = require('path'),
        readJSON = require('./util').readJSON,
        info = readJSON(__dirname + '/../package.json'),
        directories = [],
        running = null,
        args,

        IndicatorsEnum = {
            SUCCESS:    '✓',
            FAILURE:    '✕'
        },

        LogEnum = {
            INFO:       'INFO',
            ERROR:      'ERROR',
            DEBUG:      'DEBUG',
            WARNING:    'WARNING'
        },

        components = {

            grunt: {
                name: 'Grunt',
                loaded: null,
                require: 'grunt',
                onLoad: grunt,
                onComplete: done,
                config: {
                    npmTasks: ['jetfuel-grunt-tasks']
                }
            },

            bower: {
                name: 'Bower',
                loaded: null,
                require: 'bower',
                onLoad: bower
            }

        },

        cli = {

            "--version": function() {
                util.puts('Version: ' + require('./version').call());
                done();
            },

            init: function() {
                var init = require('./init');
                init.done = done;
                init.apply(init, args);
            },

            grunt:  curry(load, [components.grunt.require]),
            bower:  curry(load, [components.bower.require])

        },

        directives = {

            json: function(file) {
                var data = fs.existsSync(file) && readJSON(file) || {};
                data[SRC_FILE] = file;
                return data;
            }

        };

    function jetfuel() {
        load(components.grunt.require, { facade: true });
    }

    function curry(fn, args, ctx) {
       return function() {
         return fn.apply(ctx || this, args);
       }
    }

    function pushd(directory) {
        directories.push(process.cwd());
        process.chdir(directory);
    }

    function popd() {
        return directories.pop();
    }

    function directive(value) {
        var parts = typeof value === 'string' && value.match(/^<(.*)>$/),
            directive = parts && (parts = parts[1].split(':')) && directives[parts[0]];

        return directive && directive.apply(this, parts.shift() && parts) || value;
    }

    function msg(str, type) {
        return '[' + (LogEnum[type] || LogEnum.INFO) + '] ' + (running && running.name + ': ' || '') + str;
    }

    function errorMsg(str) {
        return msg(str, LogEnum.ERROR).red;
    }

    function bower(component, options) {
        var config = require(__dirname + '/../node_modules/bower/lib/core/config'),
            vendor = process.jetfuel.config.bower.vendor,
            dependencies = vendor.dependencies,
            commands = component.commands,
            command = args[0],
            subargs = args.splice(1),
            hooks = {
                install:    curry(writeDependencies),
                uninstall:  curry(writeDependencies, [true])
            };

        function writeDependencies(uninstall) {
            if(!subargs.length) for(var dependency in vendor.dependencies) subargs.push([dependency, vendor.dependencies[dependency] || BOWER_LATEST].join('#'))
            else {
                subargs.forEach(uninstall && removeDependency || addDependency);
                fs.writeFileSync(vendor[SRC_FILE], JSON.stringify(remove(SRC_FILE, require(components.grunt.require).utils._.extend({}, vendor)), null, JSON_SPACES));
            }
        }

        function addDependency(dependency) {
            dependency = dependency.split('#');
            dependencies[dependency[0]] = dependency[1] || BOWER_LATEST;
        }

        function removeDependency(dependency) {
            remove(dependency.split('#')[0], dependencies);
        }

        function remove(k, o) {
            o[k] = undefined;
            delete o[k];
            return o;
        }

        function log(data, type) { data && util[type == LogEnum.ERROR ? 'error' : 'puts'](data); }

        config.directory = vendor.directory || DEFAULT_BOWER_DIR;

        (commands[command] || commands[DEFAULT_BOWER_COMMAND]).apply(component, [subargs])
            .on('data',  log)
            .on('error', function(data) {
                log(data, LogEnum.ERROR);
                done(1);
            })
            .on('end', function(data) {
                log(data);
                hooks[command] && hooks[command]();
                done();
            });
    }

    function begin(component) {
        running = component;
    }

    function done(code) {
        code = code || 0;
        running = null;
        if(code === 0) util.puts(IndicatorsEnum.SUCCESS.green + ' Done.');
        else util.error(IndicatorsEnum.FAILURE + ' Done.');
        process.exit(code);
    }

    function setLogging() {<commit_msg>Fixed bower unistall and install issues<commit_after>(function(undefined) {
    'use strict';

    var ERROR_CONFIG_NOT_FOUND  = 2,
        ERROR_DEP_NOT_FOUND     = 3,
        JSON_SPACES             = 4,
        ENOENT                  = 'ENOENT',
        DEFAULT_BOWER_COMMAND   = 'help',
        DEFAULT_BOWER_DIR       = 'vendor',
        SRC_FILE                = '_source',
        GRUNT_FILE              = 'grunt.js',
        JETFUEL_FILE            = '.jetfuel.json',
        BOWER_LATEST            = '*';

    var util = require('util'),
        fs = require('fs'),
        path = require('path'),
        readJSON = require('./util').readJSON,
        info = readJSON(__dirname + '/../package.json'),
        directories = [],
        running = null,
        args,

        IndicatorsEnum = {
            SUCCESS:    '✓',
            FAILURE:    '✕'
        },

        LogEnum = {
            INFO:       'INFO',
            ERROR:      'ERROR',
            DEBUG:      'DEBUG',
            WARNING:    'WARNING'
        },

        components = {

            grunt: {
                name: 'Grunt',
                loaded: null,
                require: 'grunt',
                onLoad: grunt,
                onComplete: done,
                config: {
                    npmTasks: ['jetfuel-grunt-tasks']
                }
            },

            bower: {
                name: 'Bower',
                loaded: null,
                require: 'bower',
                onLoad: bower
            }

        },

        cli = {

            "--version": function() {
                util.puts('Version: ' + require('./version').call());
                done();
            },

            init: function() {
                var init = require('./init');
                init.done = done;
                init.apply(init, args);
            },

            grunt:  curry(load, [components.grunt.require]),
            bower:  curry(load, [components.bower.require])

        },

        directives = {

            json: function(file) {
                var data = fs.existsSync(file) && readJSON(file) || {};
                data[SRC_FILE] = file;
                return data;
            }

        };

    function jetfuel() {
        load(components.grunt.require, { facade: true });
    }

    function curry(fn, args, ctx) {
       return function() {
         return fn.apply(ctx || this, args);
       }
    }

    function pushd(directory) {
        directories.push(process.cwd());
        process.chdir(directory);
    }

    function popd() {
        return directories.pop();
    }

    function directive(value) {
        var parts = typeof value === 'string' && value.match(/^<(.*)>$/),
            directive = parts && (parts = parts[1].split(':')) && directives[parts[0]];

        return directive && directive.apply(this, parts.shift() && parts) || value;
    }

    function msg(str, type) {
        return '[' + (LogEnum[type] || LogEnum.INFO) + '] ' + (running && running.name + ': ' || '') + str;
    }

    function errorMsg(str) {
        return msg(str, LogEnum.ERROR).red;
    }

    function bower(component, options) {
        var config = require(__dirname + '/../node_modules/bower/lib/core/config'),
            vendor = process.jetfuel.config.bower.vendor,
            dependencies = vendor.dependencies,
            commands = component.commands,
            command = args[0],
            subargs = args.splice(1),
            nowrite = false,
            hooks = {
                install:    curry(writeDependencies),
                uninstall:  curry(writeDependencies, [true])
            };

        function writeDependencies(uninstall) {
            if(nowrite) return;
            subargs.forEach(uninstall && removeDependency || addDependency);
            fs.writeFileSync(vendor[SRC_FILE], JSON.stringify(remove(SRC_FILE, require(components.grunt.require).utils._.extend({}, vendor)), null, JSON_SPACES));
        }

        function addDependency(dependency) {
            dependency = dependency.split('#');
            dependencies[dependency[0]] = dependency[1] || BOWER_LATEST;
        }

        function removeDependency(dependency) {
            remove(dependency.split('#')[0], dependencies);
        }

        function remove(k, o) {
            o[k] = undefined;
            delete o[k];
            return o;
        }

        function log(data, type) { data && util[type == LogEnum.ERROR ? 'error' : 'puts'](data); }

        config.directory = vendor.directory || DEFAULT_BOWER_DIR;

        if(command == 'uninstall') hooks[command] && hooks[command]();
        else if(command == 'install' && !subargs.length) {
            for(var dependency in vendor.dependencies) {
                subargs.push([dependency, vendor.dependencies[dependency] || BOWER_LATEST].join('#'));
                nowrite = true;
            }
        }

        try {
            (commands[command] || commands[DEFAULT_BOWER_COMMAND]).apply(component, [subargs, {}])
                .on('data',  log)
                .on('end', function(data) {
                    hooks[command] && hooks[command]();
                    log(data);
                    done();
                })
                .on('error', function(data) {
                    log(data, LogEnum.ERROR);
                    done(1);
                });
        } catch(e) {
            util.error(e);
            done(1);
        }
    }

    function begin(component) {
        running = component;
    }

    function done(code) {
        code = code || 0;
        running = null;
        if(code === 0) util.puts(IndicatorsEnum.SUCCESS.green + ' Done.');
        else util.error(IndicatorsEnum.FAILURE + ' Done.');
        process.exit(code);
    }

    function setLogging() {
{'fraction_non_alphanumeric': 0.13609256786826882, 'fraction_numerical': 0.002403204272363151, 'mean_word_length': 1.4852908648529086, 'pattern_counts': {'":': 2, '<': 5, '<?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': '1909366', 'n_tokens_mistral': 3218, 'n_tokens_neox': 3011, 'n_words': 573}