all files / lib/ bootstrap.js

100% Statements 16/16
50% Branches 1/2
100% Functions 3/3
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 32 33 34 35 36                                       
'use strict';
 
var path = require('path');
 
var _ = require('lodash');
var Promise = require('bluebird');
 
var fecom = require('./fecom');
var getProfile = require('./profile/getProfile');
var getConfig = require('./component/getConfig');
var Fecom = fecom.constructor;
 
module.exports = function (env, userProfile, userConfig) {
  var profilePromise = (userProfile ? fecom.async(userProfile) : getProfile());
  Fecom.defaults.config = _.assign({}, Fecom.defaults.config, userConfig);
 
  fecom.root = env.cwd;
 
  Promise
    .try(function () {
      return Promise
        .props({
          userProfile: profilePromise,
          userConfig: getConfig()
        });
    })
    .then(function (results) {
      var profile = results.userProfile;
      var config = results.userConfig;
      fecom.initialize({
        cwd: env.cwd
      }, config, profile);
    })
    .catch(fecom.errorHandler);
 
};