src/lib/index.js
function expandVars(target, options) {
  const vars = options.vars || {};
  const regexp = /\$\{(\w+)\}/g;

  if (typeof target === "string") {
    return _expand(target);
  }
  for (let key in target) {
    target[key] = _expand(target[key]);
  }
  return target;

  function _expand(val) {
    let expanded = val;
    let match;

    while (match = regexp.exec(val)) {
      const varname = match[1];
      const varval = vars[varname] || process.env[varname];
      if (!varval) {
        debug(`could not expand variable \${${varname}}`);
        continue;
      }
      expanded = expanded.replace(`\${${varname}}`, varval);
    }
    return expanded;
  }
}
function expandVars(target, options) {
  const vars = options.vars || {};
  const regexp = /\$\{(\w+)\}/g;

  if (typeof target === "string") {
    return _expand(target);
  }
  for (let key in target) {
    target[key] = _expand(target[key]);
  }
  return target;

  function _expand(val) {
    let expanded = val;
    let match;

    while (match = regexp.exec(val)) {
      const varname = match[1];
      const varval = vars[varname] || process.env[varname];
      if (!varval) {
        debug(`could not expand variable \${${varname}}`);
        continue;
      }
      expanded = expanded.replace(`\${${varname}}`, varval);
    }
    return expanded;
  }
}
function expandVars ( target , options ) { const vars = options . vars || { } ; const regexp = / \$\{(\w+)\} / g ; if ( typeof target === "string" ) { return _expand ( target ) ; } for ( let key in target ) { target [ key ] = _expand ( target [ key ] ) ; } return target ; function _expand ( val ) { let expanded = val ; let match ; while ( match = regexp . exec ( val ) ) { const varname = match [ 1 ] ; const varval = vars [ varname ] || process . env [ varname ] ; if ( ! varval ) { debug ( ` \$ ${ varname } ` ) ; continue ; } expanded = expanded . replace ( ` \$ ${ varname } ` , varval ) ; } return expanded ; } }
Expand variables, using variables from the `options` object,
or process environment.
Modifies the passed object in place.

@private
@param  {String|Object} target - object with parameters
@param  {Object} options - test configurations
@return {String|Object}
Expand variables using variables from the options object or process environment . Modifies the passed object in place .