all files / lib/component/ getToInstall.js

100% Statements 16/16
83.33% Branches 5/6
100% Functions 4/4
100% Lines 16/16
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            12×       12×     11× 14× 14×     11× 14×    
'use strict';
 
var path = require('path');
 
var fs = require('graceful-fs');
 
var fecom = require('../fecom');
var Component = require('./Component');
 
module.exports = function (parsedList) {
 
  if (!parsedList.length) {
    parsedList = fecom.config.dependencies || [];
    parsedList = parsedList.map(function (str) {
      return fecom.parse(str);
    });
  }
 
  if (!parsedList.length) {
    throw new Error(fecom.i18n('NO_COMPONENT_TO_INSTALL'));
  }
 
  parsedList = parsedList.map(function (parsed) {
    parsed.specified = true;
    return parsed;
  });
 
  return Promise.all(parsedList.map(function (parsed) {
    return fecom.async(new Component(parsed, 'remote'));
  }));
};