All files / platform/cli/src/commands/utils findRequiredOhifExtensionsForMode.js

0% Statements 0/17
0% Branches 0/2
0% Functions 0/4
0% Lines 0/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42                                                                                   
import { validateExtension } from './validate.js';
 
export default async function findRequiredOhifExtensionsForMode(yarnInfo) {
  // Get yarn info file and get peer dependencies
  if (!yarnInfo.peerDependencies) {
    // No ohif-extension dependencies
    return;
  }
 
  const peerDependencies = yarnInfo.peerDependencies;
  const dependencies = [];
  const ohifExtensions = [];
 
  Object.keys(peerDependencies).forEach(packageName => {
    dependencies.push({
      packageName,
      version: peerDependencies[packageName],
    });
  });
 
  const promises = [];
 
  // Fetch each npm json and check which are ohif extensions
  for (let i = 0; i < dependencies.length; i++) {
    const dependency = dependencies[i];
    const { packageName, version } = dependency;
    const promise = validateExtension(packageName, version)
      .then(() => {
        ohifExtensions.push({ packageName, version });
      })
      .catch(() => {});
 
    promises.push(promise);
  }
 
  // Await all the extensions // TODO -> Improve so we async install each
  // extension and await all of those promises instead.
  await Promise.all(promises);
 
  return ohifExtensions;
}