<commit_before>define(function(require, module, exports) {
    main.consumes = ["Plugin", "settings", "fs", "c9", "preferences", "run"];
    main.provides = ["build"];
    return main;

    function main(options, imports, register) {
        var Plugin      = imports.Plugin;
        var settings    = imports.settings;
        var prefs       = imports.preferences;
        var run         = imports.run;
        var fs          = imports.fs;
        var c9          = imports.c9;
        
        /***** Initialization *****/
        
        var plugin  = new Plugin("Ajax.org", main.consumes);
        var emit    = plugin.getEmitter();
        
        var builders   = options.builders;
        var processes  = [];
        var base       = options.base;
        
        var loaded = false;
        function load(){
            if (loaded) return false;
            loaded = true;
            
            // Settings
            settings.on("read", function(e){
                // Defaults
                settings.setDefaults("project/build", [
                    ["path", "~/.c9/builders"]
                ]);
            }, plugin);
            
            settings.on("write", function(e){
                
            }, plugin);
            
            // Preferences
            prefs.add({
                "Project" : {
                    "Build" : {
                        position : 400,
                        "Builder Path in Workspace" : {
                           type : "textbox",
                           path : "project/build/@path",
                           position : 1000
                        }
                    }
                }
            }, plugin);

            // Check after state.change
            c9.on("stateChange", function(e){
                
            }, plugin);
            
            // @todo Could consider adding a watcher to ~/.c9/runners
            
            listBuilders(function(err, files){
                files.forEach(function(file){
                    if (!builders[file]) {
                        getBuilder(file, false, function(err, builder){
                            builders[file] = builder;
                        });
                    }
                })
            })
        }
        
        /***** Methods *****/
        
        function listBuilders(callback){
            var builders = Object.keys(options.builders || {});
            fs.readdir(settings.get("project/build/@path"), function(err, files){
//                if (err && err.code == "ENOENT")
//                    return callback(err);
                
                if (files) {
                    files.forEach(function(file){
                        builders.push(file.name);
                    });
                }
                
                callback(null, builders);<commit_msg>Remove settings loading from critical path - potential cause for bugs<commit_after>define(function(require, module, exports) {
    main.consumes = ["Plugin", "settings", "fs", "c9", "preferences", "run"];
    main.provides = ["build"];
    return main;

    function main(options, imports, register) {
        var Plugin      = imports.Plugin;
        var settings    = imports.settings;
        var prefs       = imports.preferences;
        var run         = imports.run;
        var fs          = imports.fs;
        var c9          = imports.c9;
        
        /***** Initialization *****/
        
        var plugin  = new Plugin("Ajax.org", main.consumes);
        var emit    = plugin.getEmitter();
        
        var builders   = options.builders;
        var processes  = [];
        var base       = options.base;
        
        var loaded = false;
        function load(){
            if (loaded) return false;
            loaded = true;
            
            // Settings
            settings.on("read", function(e){
                // Defaults
                settings.setDefaults("project/build", [
                    ["path", "~/.c9/builders"]
                ]);
                
                // @todo Could consider adding a watcher to ~/.c9/runners
                listBuilders(function(err, files){
                    files.forEach(function(file){
                        if (!builders[file]) {
                            getBuilder(file, false, function(err, builder){
                                builders[file] = builder;
                            });
                        }
                    });
                });
            }, plugin);
            
            settings.on("write", function(e){
                
            }, plugin);
            
            // Preferences
            prefs.add({
                "Project" : {
                    "Build" : {
                        position : 400,
                        "Builder Path in Workspace" : {
                           type : "textbox",
                           path : "project/build/@path",
                           position : 1000
                        }
                    }
                }
            }, plugin);

            // Check after state.change
            c9.on("stateChange", function(e){
                
            }, plugin);
        }
        
        /***** Methods *****/
        
        function listBuilders(callback){
            var builders = Object.keys(options.builders || {});
            fs.readdir(settings.get("project/build/@path"), function(err, files){
//                if (err && err.code == "ENOENT")
//                    return callback(err);
                
                if (files) {
                    files.forEach(function(file){
                        builders.push(file.name);
                    });
                }
                
                callback(null, builders);
{'fraction_non_alphanumeric': 0.11374163664436439, 'fraction_numerical': 0.004460456338994682, 'mean_word_length': 0.9756014910199933, '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': '2024515', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1322, 'n_words': 284}