All files / src/config index.js

87.5% Statements 7/8
50% Branches 2/4
50% Functions 1/2
87.5% Lines 7/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211x 1x 1x       1x     6x     6x           6x    
const parse = require('./parse');
const schema = require('./schema');
const env = require('./env');
 
// Accept the user options (first argument) and then a list with all the plugins
// This will allow us to use the plugin's schemas as well
module.exports = async (user = {}, plugins = []) => {
 
  // First and most important is the core and the user-defined options
  const options = await parse(schema, user, env);
 
  // Then load plugin options namespaced with the name in parallel
  await Promise.all(plugins.map(async ({ name, options: def = {}} = {}) => {
    options[name] = await parse(def, user[name], env, options);
  }));
 
  // console.log(options);
 
  return options;
};