all files / prolific.root/ configure.js

100% Statements 16/16
100% Branches 10/10
100% Functions 1/1
100% Lines 16/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                      
function configure (env, configuration) {
    if (configuration == null) {
        configuration = { processors: [] }
    } else if (/^\s*{/.test(configuration)) {
        configuration = JSON.parse(configuration)
    } else if (configuration == 'inherit') {
        configuration = 'PROLIFIC_CONFIGURATION'
    } else {
        configuration = env[configuration]
    }
    if (typeof configuration == 'object') {
        var defaults = {
            processors: [],
            levels: []
        }
        for (var key in defaults) {
            if (!(key in configuration)) {
                configuration[key] = defaults[key]
            }
        }
        return configuration
    }
    return configure(env, configuration)
}
 
module.exports = configure