function addConfigPackage()

in lib/multiGraphBuilder.js [76:106]


function addConfigPackage(paths, applicationRoot, npmName) {
  let root = null;
  let packageInstance = null;
  npmName = npmName.trim();
  if (!npmName.startsWith('.')) {
    try {
      packageInstance = require(npmName);
    } catch (cannotRequire) {
      const error = new Error(`While trying to identify configuration graphs, ${npmName} could not be required`);
      error.innerError = cannotRequire;
      throw error;
    }
    if (typeof(packageInstance) === 'string') {
      root = packageInstance;
    } else {
      throw new Error(`The package ${npmName} instance is not of type string. For the configuration graph system it should be a string (a path).`);
    }
  } else {
    root = path.resolve(path.join(applicationRoot, npmName));
  }
  try {
    fs.statSync(root);
    paths.push(root);
  } catch (notFound) {
    if (packageInstance) {
      throw new Error(`While instantiating "${npmName}, the returned string value was not a valid path: ${root}`);
    } else {
      throw new Error(`Could not locate the local configuration directory for package "${npmName}": ${root}`);
    }
  }
}