All files / server/utils/options index.js

100% Statements 8/8
33.33% Branches 1/3
100% Functions 2/2
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1911x 11x 11x       11x     99x     99x 990x     99x    
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, env, user);
 
  // Then load plugin options namespaced with the name in parallel
  await Promise.all(plugins.map(async ({ name, options: def = {}}) => {
    options[name] = await parse(def, env, user[name], options);
  }));
 
  return options;
};