lib/cog.js
function getConfig(name, def) {

        var i, j;

        // Load initital config.
        if (!config) {

            var external;

            config = grunt.config.get('cog') || {options: {}};

            // Expand general external definitions to category specific definitions.
            if (config.options.external instanceof Array) {
                external = config.options.external;
                config.options.external = {lib: [], css: [], fonts: []};
                for (i=0; i < external.length; i++) {
                    if (!db.categories[external[i]]) {
                        grunt.fail.fatal("Cannot figure out applicaple categories for external dependency: " + external[i]);
                    }
                    for(j = 0; j < db.categories[external[i]].length; j++) {
                        config.options.external[db.categories[external[i]][j]].push(external[i]);
                    }
                }
            }

            // Expand also for unit tests.
            if (config.options.test && config.options.test.unit && config.options.test.unit.external instanceof Array) {
                external = config.options.test.unit.external;
                config.options.test.unit.lib = [];
                config.options.test.unit.css = [];
                for (i=0; i < external.length; i++) {
                    if (!db.categories[external[i]]) {
                        grunt.fail.fatal("Cannot figure out applicaple categories for external dependency: " + external[i]);
                        continue;
                    }
                    for(j = 0; j < db.categories[external[i]].length; j++) {
                        config.options.test.unit[db.categories[external[i]][j]].push(external[i]);
                    }
                }
            }
        }

        var ret = config.options;

        if (!name) {
            return ret;
        }

        var parts = name.split('.');
        for (i=0; i < parts.length; i++) {
            if (!ret) {
                return def;
            }
            ret = ret[parts[i]];
        }

        return ret || def;
    }
function getConfig(name, def) {

        var i, j;

        // Load initital config.
        if (!config) {

            var external;

            config = grunt.config.get('cog') || {options: {}};

            // Expand general external definitions to category specific definitions.
            if (config.options.external instanceof Array) {
                external = config.options.external;
                config.options.external = {lib: [], css: [], fonts: []};
                for (i=0; i < external.length; i++) {
                    if (!db.categories[external[i]]) {
                        grunt.fail.fatal("Cannot figure out applicaple categories for external dependency: " + external[i]);
                    }
                    for(j = 0; j < db.categories[external[i]].length; j++) {
                        config.options.external[db.categories[external[i]][j]].push(external[i]);
                    }
                }
            }

            // Expand also for unit tests.
            if (config.options.test && config.options.test.unit && config.options.test.unit.external instanceof Array) {
                external = config.options.test.unit.external;
                config.options.test.unit.lib = [];
                config.options.test.unit.css = [];
                for (i=0; i < external.length; i++) {
                    if (!db.categories[external[i]]) {
                        grunt.fail.fatal("Cannot figure out applicaple categories for external dependency: " + external[i]);
                        continue;
                    }
                    for(j = 0; j < db.categories[external[i]].length; j++) {
                        config.options.test.unit[db.categories[external[i]][j]].push(external[i]);
                    }
                }
            }
        }

        var ret = config.options;

        if (!name) {
            return ret;
        }

        var parts = name.split('.');
        for (i=0; i < parts.length; i++) {
            if (!ret) {
                return def;
            }
            ret = ret[parts[i]];
        }

        return ret || def;
    }
function getConfig ( name , def ) { var i , j ; // Load initital config. if ( ! config ) { var external ; config = grunt . config . get ( 'cog' ) || { options : { } } ; // Expand general external definitions to category specific definitions. if ( config . options . external instanceof Array ) { external = config . options . external ; config . options . external = { lib : [ ] , css : [ ] , fonts : [ ] } ; for ( i = 0 ; i < external . length ; i ++ ) { if ( ! db . categories [ external [ i ] ] ) { grunt . fail . fatal ( "Cannot figure out applicaple categories for external dependency: " + external [ i ] ) ; } for ( j = 0 ; j < db . categories [ external [ i ] ] . length ; j ++ ) { config . options . external [ db . categories [ external [ i ] ] [ j ] ] . push ( external [ i ] ) ; } } } // Expand also for unit tests. if ( config . options . test && config . options . test . unit && config . options . test . unit . external instanceof Array ) { external = config . options . test . unit . external ; config . options . test . unit . lib = [ ] ; config . options . test . unit . css = [ ] ; for ( i = 0 ; i < external . length ; i ++ ) { if ( ! db . categories [ external [ i ] ] ) { grunt . fail . fatal ( "Cannot figure out applicaple categories for external dependency: " + external [ i ] ) ; continue ; } for ( j = 0 ; j < db . categories [ external [ i ] ] . length ; j ++ ) { config . options . test . unit [ db . categories [ external [ i ] ] [ j ] ] . push ( external [ i ] ) ; } } } } var ret = config . options ; if ( ! name ) { return ret ; } var parts = name . split ( '.' ) ; for ( i = 0 ; i < parts . length ; i ++ ) { if ( ! ret ) { return def ; } ret = ret [ parts [ i ] ] ; } return ret || def ; }
Safe fetch of configuration variable.
Safe fetch of configuration variable .