function buildNestedCfs(config, KesClass, options) {
  const limit = pLimit(1);
  if (config.nested_templates) {
    const nested = config.nested_templates;
    console.log('Nested templates are found!');
    const ps = Object.keys(nested).map((name) => limit(() => {
      console.log(`Compiling nested template for ${name}`);

      const newOptions = Object.assign({}, options);
      newOptions.cfFile = nested[name].cfFile;
      newOptions.configFile = nested[name].configFile;

      // no templates are used in nested stacks
      delete newOptions.template;
      delete newOptions.deployment;

      // use the parent stackname
      newOptions.stack = config.stack;
      newOptions.parent = config;
      const nestedConfig = new Config(newOptions);

      // get the bucket name from the parent
      if (!nestedConfig.bucket) {
        nestedConfig.bucket = utils.getSystemBucket(config);
      }

      // add nested deployment name
      nestedConfig.nested_cf_name = name;

      const kes = new KesClass(nestedConfig);
      return kes.uploadCF().then((uri) => {
        config.nested_templates[name].url = uri;
      });
    }));
    return Promise.all(ps)
      .then(() => config)
      .catch(utils.failure);
  }
  return Promise.resolve(config);
}
function buildNestedCfs(config, KesClass, options) {
  const limit = pLimit(1);
  if (config.nested_templates) {
    const nested = config.nested_templates;
    console.log('Nested templates are found!');
    const ps = Object.keys(nested).map((name) => limit(() => {
      console.log(`Compiling nested template for ${name}`);

      const newOptions = Object.assign({}, options);
      newOptions.cfFile = nested[name].cfFile;
      newOptions.configFile = nested[name].configFile;

      // no templates are used in nested stacks
      delete newOptions.template;
      delete newOptions.deployment;

      // use the parent stackname
      newOptions.stack = config.stack;
      newOptions.parent = config;
      const nestedConfig = new Config(newOptions);

      // get the bucket name from the parent
      if (!nestedConfig.bucket) {
        nestedConfig.bucket = utils.getSystemBucket(config);
      }

      // add nested deployment name
      nestedConfig.nested_cf_name = name;

      const kes = new KesClass(nestedConfig);
      return kes.uploadCF().then((uri) => {
        config.nested_templates[name].url = uri;
      });
    }));
    return Promise.all(ps)
      .then(() => config)
      .catch(utils.failure);
  }
  return Promise.resolve(config);
}
function buildNestedCfs ( config , KesClass , options ) { const limit = pLimit ( 1 ) ; if ( config . nested_templates ) { const nested = config . nested_templates ; console . log ( 'Nested templates are found!' ) ; const ps = Object . keys ( nested ) . map ( ( name ) => limit ( ( ) => { console . log ( ` ${ name } ` ) ; const newOptions = Object . assign ( { } , options ) ; newOptions . cfFile = nested [ name ] . cfFile ; newOptions . configFile = nested [ name ] . configFile ; // no templates are used in nested stacks delete newOptions . template ; delete newOptions . deployment ; // use the parent stackname newOptions . stack = config . stack ; newOptions . parent = config ; const nestedConfig = new Config ( newOptions ) ; // get the bucket name from the parent if ( ! nestedConfig . bucket ) { nestedConfig . bucket = utils . getSystemBucket ( config ) ; } // add nested deployment name nestedConfig . nested_cf_name = name ; const kes = new KesClass ( nestedConfig ) ; return kes . uploadCF ( ) . then ( ( uri ) => { config . nested_templates [ name ] . url = uri ; } ) ; } ) ) ; return Promise . all ( ps ) . then ( ( ) => config ) . catch ( utils . failure ) ; } return Promise . resolve ( config ) ; }
Builds templates nested in the main template
using the specified config and cf file paths

@param {object} config Kes config object
@param {object} KesClass the Kes Class
@param {object} options The options passed by the commander library
@return {Promise} returns a promise of an updated Kes config object
Builds templates nested in the main template using the specified config and cf file paths