Read and/or extend/replace default config file,
prepare and optimize plugins array.

@param {Object} [config] input config
@return {Object} output config
184172
function(config) {

        var defaults = {plugins: []};
        config = typeof config == 'object' && config || {};

        if (config.plugins && !Array.isArray(config.plugins)) {
            return { error: 'Error: Invalid plugins list. Provided \'plugins\' in config should be an array.' };
        }

        if (config.full) {
            defaults = config;

            if (Array.isArray(defaults.plugins)) {
                defaults.plugins = preparePluginsArray(defaults.plugins);
            }
        } else {
            defaults = {
              plugins: preparePluginsArray(defaults.plugins)
            }
            defaults = extendConfig(defaults, config);
        }

        if ('floatPrecision' in config && Array.isArray(defaults.plugins)) {
            defaults.plugins.forEach(function(plugin) {
                if (plugin.params && ('floatPrecision' in plugin.params)) {
                    // Don't touch default plugin params
                    plugin.params = EXTEND({}, plugin.params, { floatPrecision: config.floatPrecision });
                }
            });
        }

        if (Array.isArray(defaults.plugins)) {
            defaults.plugins = optimizePluginsArray(defaults.plugins);
        }

        return defaults;

    }
1145228
function Config (config, defaultConfig) {
  validateConfig(config);
  deepAssign(this, defaultConfig || Config.defaults);

  if (config) {
    deepAssign(this, config);
  }
}
940320
function loadConfig(configToLoad) {
  var config = {};
  var filePath = '';

  if (configToLoad) {

    if (isObject(configToLoad)) {
      config = configToLoad;
    } else {
      filePath = configToLoad;
      config = readConfigFromFile(filePath);
    }

    if (!config.rules) {
      config.rules = {};
    }
    config.rules = Object.keys(config.rules).reduce(function(obj, ruleId) {
      if (!Array.isArray(config.rules[ruleId])) {
        obj[ruleId] = [config.rules[ruleId]];
      }
      return obj;
    }, {});

    validator.validate(config, filePath);

        // If an `extends` property is defined, it represents a configuration file to use as
        // a 'parent'. Load the referenced file and merge the configuration recursively.
    if (config.extends) {
      var configExtends = config.extends;

      if (!Array.isArray(config.extends)) {
        configExtends = [config.extends];
      }

            // Make the last element in an array take the highest precedence
      config = configExtends.reduceRight(function(previousValue, parentPath) {

        if (parentPath === 'nplint:recommended') {
                    // Add an explicit substitution for eslint:recommended to conf/eslint.json
                    // this lets us use the eslint.json file as the recommended rules
          parentPath = path.resolve(__dirname, '../conf/nplint.json');
        } else if (isFilePath(parentPath)) {
                  // If the `extends` path is relative, use the directory of the current configuration
                  // file as the reference point. Otherwise, use as-is.
          parentPath = (!isAbsolutePath(parentPath) ?
                    path.join(path.dirname(filePath), parentPath) :
                    parentPath
                );
        }

        try {
          return util.mergeConfigs(loadConfig(parentPath), previousValue);
        } catch (e) {
                  // If the file referenced by `extends` failed to load, add the path to the
                  // configuration file that referenced it to the error message so the user is
                  // able to see where it was referenced from, then re-throw
          e.message += '\nReferenced from: ' + filePath;
          throw e;
        }

      }, config);

    }

  }

  return config;
}
1110620
def configuration(self, plugin):
        
        conf = self.config.get(plugin, "default;").split(';')
        if len(conf) == 1:
            conf.append('')
        return tuple(conf)
831333
function (defaults, configure) {
        for (var key in defaults) {
            if (defaults.hasOwnProperty(key)) {
                if (typeof defaults[key] === 'object') {
                    // recursive
                    if (typeof configure[key] === 'object') {
                        overwriteConfig(defaults[key], configure[key]);
                    }
                } else {
                    // copy directly
                    if (typeof configure[key] !== 'undefined') {
                        defaults[key] = configure[key];
                    }
                }
            }
        }
    }
452852
function configGen() {
  return {
    input: 'src/index.ts',
    output: {
      file: 'dist/web/buttplug.js',
      format: 'iife',
      name: "Buttplug"
    },
    plugins: [
      nodeResolve({
        jsnext: true,
        main: true,
        extensions: [ '.ts', '.js', '.json' ],
        browser: true
      }),
      typescript({ tsconfigOverride: { compilerOptions: { module: "ES2015" } } }),
      json(),
      nodeBuiltins(),
      nodeGlobals(),
      commonjs({
        // non-CommonJS modules will be ignored, but you can also
        // specifically include/exclude files
        include: ['../../node_modules/**', './node_modules/**'],  // Default: undefined
      }),
    ]
  };
}
145974
function(cfg, callback) {
  var paths = cfg.input_files || cfg.input_file || cfg.input_dir;
  if (!Array.isArray(paths)) {
    paths = [paths];
  }
  
  watchr.watch({
    paths: paths,
    listener: function(eventName,filePath,fileCurrentStat,filePreviousStat){
      console.log(formatLog('File changed:', filePath));
      
      var singleFileCfg,
          outputDir,
          logTaskError = function(msg) {
            console.log('\n'+msg.red);
          };

      // Detect what build configuration the file belongs to
      if (config.scripts.indexOf(cfg) !== -1) {
        // rebuild scripts
        buildScripts(cfg, function(err){
          if (err) {
            logTaskError('Scripts not saved!');
          }
        });
      } else if (config.styles.indexOf(cfg) !== -1) {
        // rebuild styles
        buildStyles(cfg, function(err){
          if (err) {
            logTaskError('Styles not saved!');
          }
        });
      } else if (config.copy_files.indexOf(cfg) !== -1) {
        // copy files
        singleFileCfg = {input_files: [filePath], output_dir: cfg.output_dir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_file.indexOf(cfg) !== -1) {
        // copy/rename single file
        singleFileCfg = {input_file: filePath, output_file: cfg.output_file};
        copyFile(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_dir.indexOf(cfg) !== -1) {
        // copy single directory
        outputDir = path.dirname(filePath).replace(cfg.input_dir, cfg.output_dir);
        singleFileCfg = {input_files: [filePath], output_dir: outputDir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('Directory not copied!');
          }
        });
      }
    },
    next: function(err,watcher){
      if (err) {
        callback(err);
      } else {
        callback();
      }
    }
  });
}
632186
function setup() {
    return browser.getProcessedConfig()
        .then((configuration) => {
            let cucumberFormat = configuration.cucumberOpts.format;

            IS_JSON_FORMAT = cucumberFormat && cucumberFormat.includes('json');

            if (Array.isArray(cucumberFormat)) {
                IS_JSON_FORMAT = cucumberFormat.find((format) => {
                    cucumberFormat = format;
                    return format.includes('json')
                });
            }

            if (IS_JSON_FORMAT) {
                /**
                 * If options are provided override the values to the PLUGIN_CONFIG object
                 */
                if (this.config.options) {
                    Object.assign(PLUGIN_CONFIG, this.config.options);
                }

                /**
                 * Get the JSON folder path and file name if they are still empty
                 */
                const formatPathMatch = cucumberFormat.match(/(.+):(.+)/);
                const filePathMatch = formatPathMatch[2].match(/(.*)\/(.*)\.json/);

                // Get the cucumber results path
                PLUGIN_CONFIG.cucumberResultsPath = filePathMatch[1];

                // Get the cucumber report name
                PLUGIN_CONFIG.cucumberReportName = filePathMatch[2];

                /**
                 * If the json output folder is still default, then create a new one
                 */
                if (PLUGIN_CONFIG.jsonOutputPath === JSON_OUTPUT_FOLDER) {
                    PLUGIN_CONFIG.jsonOutputPath = path.join(PLUGIN_CONFIG.cucumberResultsPath, JSON_OUTPUT_FOLDER);
                }

                /**
                 * Check whether the file name need to be unique
                 */
                PLUGIN_CONFIG.uniqueReportFileName = (Array.isArray(configuration.multiCapabilities)
                    && configuration.multiCapabilities.length > 0)
                    || typeof configuration.getMultiCapabilities === 'function'
                    || configuration.capabilities.shardTestFiles;

                /**
                 * Prepare the PID_INSTANCE_DATA
                 */
                const metadata = {
                    browser: {
                        name: '',
                        version: ''
                    },
                    device: '',
                    platform: {
                        name: '',
                        version: ''
                    }
                };

                PID_INSTANCE_DATA = {
                    pid: process.pid,
                    metadata: Object.assign(metadata, configuration.capabilities[PLUGIN_CONFIG.metadataKey] || {})
                };

                /**
                 * Create the needed folders if they are not present
                 */
                fs.ensureDirSync(PLUGIN_CONFIG.cucumberResultsPath);
                fs.ensureDirSync(PLUGIN_CONFIG.jsonOutputPath);
            } else {
                console.warn('\n### NO `JSON` FORMAT IS SPECIFIED IN THE PROTRACTOR CONF FILE UNDER `cucumberOpts.format ###`\n');
            }
        });
}
322597
def parse_config_input_output(args=sys.argv):
    
    parser = argparse.ArgumentParser(
        description='Process the input files using the given config')
    parser.add_argument(
        'config_file',
        help='Configuration file.',
        metavar='FILE', type=extant_file)
    parser.add_argument(
        'input_dir',
        help='Directory containing the input files.',
        metavar='DIR', type=extant_dir)
    parser.add_argument(
        'output_dir',
        help='Directory where the output files should be saved.',
        metavar='DIR', type=extant_dir)
    return parser.parse_args(args[1:])
642392
function encodeConfig(output, config) {
    var result = {
        values: config.getValues().toJS(),

        get: function(key, defaultValue) {
            return objectPath.get(result.values, key, defaultValue);
        },

        set: function(key, value) {
            return objectPath.set(result.values, key, value);
        }
    };

    deprecate.field(output, 'config.options', result, 'options',
        result.values, '"config.options" property is deprecated, use "config.get(key)" instead');

    deprecate.field(output, 'config.options.generator', result.values, 'generator',
        output.getGenerator(), '"options.generator" property is deprecated, use "output.name" instead');

    deprecate.field(output, 'config.options.generator', result.values, 'output',
        output.getRoot(), '"options.output" property is deprecated, use "output.root()" instead');

    return result;
}
891231
function Config(options) {
  if (!(this instanceof Config)) {
    return new Config(options);
  }

  utils.is(this, 'config');
  use(this);

  define(this, 'count', 0);
  this.options = options || {};
  this.targets = {};
  this.tasks = {};

  if (utils.isConfig(options)) {
    this.options = {};
    this.expand(options);
    return this;
  }
}
1190766
function config (args) {
    // iterate over args merging configuration to either the module or the
    // global configuration
    _.each(args, (val, key) => {
        // configuration to modify
        var config
        // create new object to merge into config
        var merge = {}
        // set key and value to merge
        merge[key] = val
        // if this is a global config option then modify global config
        if (key in defaultGlobalConfig) {
            // merge args over config with custom handler to merge arrays
            _.mergeWith(immutableApp, merge, mergeArrays)
        }
        // if this is module config then set config on module instance
        else if (key in defaultModuleConfig) {
            // merge args over config with custom handler to merge arrays
            _.mergeWith(this, merge, mergeArrays)
        }
        // throw error on invalid configuration option
        else {
            throw new Error('invalid config option '+key)
        }
    })
    // return module
    return this
}
562830
function parseConfig(book) {
    var fs = book.getFS();
    var config = book.getConfig();

    return Promise.some(CONFIG_FILES, function(filename) {
        // Is this file ignored?
        if (book.isFileIgnored(filename)) {
            return;
        }

        // Try loading it
        return fs.loadAsObject(filename)
        .then(function(cfg) {
            return fs.statFile(filename)
            .then(function(file) {
                return {
                    file: file,
                    values: cfg
                };
            });
        })
        .fail(function(err) {
            if (err.code != 'MODULE_NOT_FOUND') throw(err);
            else return Promise(false);
        });
    })

    .then(function(result) {
        var values = result? result.values : {};
        values = validateConfig(values);

        // Set the file
        if (result.file) {
            config = config.setFile(result.file);
        }

        // Merge with old values
        config = config.mergeValues(values);

        return book.setConfig(config);
    });
}
1036635
function Config(options, StateMachine) {

  options = options || {};

  this.options     = options; // preserving original options can be useful (e.g visualize plugin)
  this.defaults    = StateMachine.defaults;
  this.states      = [];
  this.transitions = [];
  this.map         = {};
  this.lifecycle   = this.configureLifecycle();
  this.init        = this.configureInitTransition(options.init);
  this.data        = this.configureData(options.data);
  this.methods     = this.configureMethods(options.methods);

  this.map[this.defaults.wildcard] = {};

  this.configureTransitions(options.transitions || []);

  this.plugins = this.configurePlugins(options.plugins, StateMachine.plugin);

}
324227
function loadExampleConfig(exampleFolder) {
  // Default config.
  let config = {build: 'build', run: 'serve:e2e'};

  try {
    const exampleConfig = fs.readJsonSync(`${exampleFolder}/${EXAMPLE_CONFIG_FILENAME}`);
    Object.assign(config, exampleConfig);
  } catch (e) {
  }

  return config;
}
237839
function preparePlugins(output) {
    var book = output.getBook();

    return Promise()

    // Only load plugins for main book
    .then(function() {
        if (book.isLanguageBook()) {
            return output.getPlugins();
        } else {
            return Plugins.loadForBook(book);
        }
    })

    // Update book's configuration using the plugins
    .then(function(plugins) {
        return Plugins.validateConfig(book, plugins)
        .then(function(newBook) {
            return output.merge({
                book: newBook,
                plugins: plugins
            });
        });
    });
}
1131720
function(configPath, configNames, config) {
	var configsUsed = [];

	config = config || projectConfig;

	// work with the raw configuration object
	if (config && config.root) {
		config = config.root();
	}

	config = convict(config);
	configPath = path.resolve(appPath, configPath);
	configNames = configNames || [];

	configNames.forEach(function(configName) {
		var file;

		// Ignore local config in production mode
		if (configName == 'local' && nodeEnv === 'production') { return; }

		file = path.join(configPath, 'config-'+configName);
		file += configName === 'default' ? '.js' : '.json';

		if (fs.existsSync(file)) {

			if (configName === 'default') {
				config = convict( require(file) );
				config.load(dynamicDefaults);
			}
			else {
				config.loadFile( file );
			}

			// logging
			configName === 'default' ? configsUsed.push('xtc defaults') : configsUsed.push(configName);
		}
	});

	// be informative
	!process.env.testRun
		&& configsUsed.push('env', 'args')
		&& console.log('configuration:', configsUsed.join(' < '));

	return config;
}