Replaces object's elements with corresponding environment variables, if defined

@param   {object} config - config object to process
@param   {array} [backRef] - back reference to the parent element
@returns {object} - resolved object
169489
function envVars(config, backRef)
{
  backRef = backRef || [];

  Object.keys(config).forEach(function(key)
  {
    var value;

    if (typeof config[key] == 'string')
    {
      // try simple match first, for non-empty value
      value = getVar.call(this, config[key], process.env);

      // if not, try parsing for variables
      if (!hasValue(value))
      {
        value = parseTokens.call(this, config[key], process.env);
      }

      // keep the entry if something's been resolved
      // empty or unchanged value signal otherwise
      if (hasValue(value))
      {
        config[key] = value;
      }
      else
      {
        delete config[key];
      }
    }
    else if (isObject(config[key]))
    {
      envVars.call(this, config[key], backRef.concat(key));
    }
    // Unsupported entry type
    else
    {
      throw new Error('Illegal key type for custom-environment-variables at ' + backRef.concat(key).join('.') + ': ' + Object.prototype.toString.call(config[key]));
    }
  }.bind(this));

  return config;
}
1055498
function rebindCallback(target, source, postSetCallback) {
  var i = 2, n = arguments.length, method;
  while (++i < n) target[method = arguments[i]] = doRebind(target, source, source[method], postSetCallback);
  return target;
}
468714
function(config, defaults) {
        var key, subdefaults, subconfig;
        for (key in defaults) {
            subdefaults = defaults[key];
            subconfig = config[key];
             if ($.isPlainObject(subdefaults)) {
                 if (!$.isPlainObject(subconfig)) {
                     subconfig = config[key] = {};
                 }
                 defaultsUpdater(subconfig, subdefaults);
                 // } else if (subconfig === undefined) {
                 //     config[key] = null;
                 // }
             } else {
                 if (subconfig === undefined) {
                     config[key] = subdefaults;
                 }
             }
        }
    }
121516
function replace(node, parent, scope, remaps) {
  var remap = remaps[node.name];
  if (!remap) return;

  var ownBinding = scope.getBindingIdentifier(node.name);
  if (ownBinding === remap.binding) {
    node.name = remap.uid;
  } else {
    // scope already has it's own binding that doesn't
    // match the one we have a stored replacement for
    if (this) this.skip();
  }
}
437458
function Surround(obj, pattern) {
  var self = this;

  var regEX = new RegExp(pattern);

  for(var fn in obj) {
    var orig = obj[fn];

    if (typeof(orig) != "function" || !regEX.test(fn))
      continue;

    // Already surrouneded.
    if (obj[fn].__stacks) {
      this.stacks = obj[fn].__stacks;
      return this;
    }

    this.stacks = this.defaults();

    // The replace of the original function.
    obj[fn] = function() {
      self.stacks.before
        .concat([orig], self.stacks.after)
        .forEach(function(fn) {
          fn.apply(obj, arguments);
        });
    };

    // Resets the stack and returns the basic func back.
    obj[fn].reset = function() {
      obj[fn] = orig;
      self.stacks = self.defaults();
    };

    // The stacks are cached in the func itself.
    obj[fn].__stacks = this.stacks;
  }
}
645810
function reref(obj,options) {
    let master = obj;
    recurse(obj,{identityDetection:true},function(obj,key,state){
        if (state.identity) {
            let replacement = jptr(master,state.identityPath);
            // ensure it's still there and we've not reffed it away
            let newRef = state.identityPath;
            if (state.identityPath !== state.path) {
                if (options && options.prefix) newRef = newRef.replace('#/',options.prefix);
                if (replacement !== false) obj[key] = { $ref: newRef }
                else if (options && options.verbose) console.warn(state.identityPath,'gone away at',state.path);
            }
        }
    });
    return obj;
}
842110
function(obj, env, keypath) {
    if (!_.isObject(obj) || _.isArray(obj)) { return; }

    if (hasKeyPath(obj, ['options', 'reconfigureOverrides', env])) {
      var options = obj.options,
          overrides = obj.options.reconfigureOverrides[env];

      for (var key in overrides) {
        var update = { 
          key: keypath+'.options.'+key,
          oldVal: (typeof options[key] === 'undefined') ? 'undefined' : util.inspect(options[key]),
        };

        if (_.isObject(options[key]) && _.isObject(overrides[key])) { 
          var newVal = _.extend(options[key], overrides[key]);
          update.newVal = util.inspect(newVal);
        } else {
          options[key] = overrides[key];
          update.newVal = util.inspect(overrides[key]);
        }

        updates.push(update);
      }
    }
    
    for (var objKey in obj) {
      updateOptions(obj[objKey], env, keypath+'.'+objKey);
    }
  }
21883
function (container) {
                if (container[parProp]) {
                    // back references already present, nothing to do
                    return;
                }
                // back references are not present yet
                container[parProp] = [];
                for (var childName in container) {
                    if (container.hasOwnProperty(childName) && __includePropForBackRef(childName)) {
                        var childValue = container[childName];
                        if (__isValidContainer(childValue)) {
                            this.__checkBackRefs(childValue);
                            // Add the container reference and property name to the child 'aria:parent' array
                            childValue[parProp].push({
                                parent : container,
                                property : childName
                            });
                            this.$raiseEvent({
                                name : 'aria-parent-metadata-added',
                                child: childValue,
                                parent: container,
                                property: childName
                            });
                        }
                    }
                }
            }
1260501
private function replaceReferences(array &$config)
    {
        foreach ($config as $key => &$value) {
            if (is_array($value)) {
                $this->replaceReferences($value);
                continue;
            }

            //~ Not string, skip
            if (!is_string($value)) {
                continue;
            }

            //~ Value not %my.reference.config%, skip
            if (!(bool) preg_match('`%(.*?)%`', $value, $matches)) {
                continue;
            }

            $referenceValue = $this->get($matches[1]);

            if ($referenceValue !== null) {
                $value = $referenceValue;
            }
        }
    }
340560
function setConfigObject (config, prev) {
    Object.keys(config).forEach(function (key) {
      var value = config[key]
      var fullKey = prev ? prev + '.' + key : key

      // if the value is an inner object and we have dot-notation
      // enabled, treat inner objects in config the same as
      // heavily nested dot notations (foo.bar.apple).
      if (typeof value === 'object' && value !== null && !Array.isArray(value) && configuration['dot-notation']) {
        // if the value is an object but not an array, check nested object
        setConfigObject(value, fullKey)
      } else {
        // setting arguments via CLI takes precedence over
        // values within the config file.
        if (!hasKey(argv, fullKey.split('.')) || (flags.defaulted[fullKey]) || (flags.arrays[fullKey] && configuration['combine-arrays'])) {
          setArg(fullKey, value)
        }
      }
    })
  }
895663
function envReplace(str, vars) {
  return str.replace(/\$?\$\{([A-Za-z0-9_]+)(:-(.*?))?\}/g, function (varStr, varName, _, defValue) {
    // Handle escaping:
    if (varStr.indexOf('$$') === 0) {
      return varStr;
    }
    // Handle simple variable replacement:
    if (vars.hasOwnProperty(varName)) {
      log.debug(`${varName} replaced in configuration file`);
      return vars[varName];
    }
    // Handle default values:
    if (defValue) {
      log.debug(`${varName} replaced with default value in configuration file`);
      return defValue;
    }
    log.warn(`Unknown variable: ${varName}. Returning null.`);
    return null;
  });
}
788302
function(){
        var _replace    = "$1" + this.config.tp + "$2" + this.config.tp,
            _al         = this.config.jade.replace( /(^\s*)(script\([^\)|^\n|^\r]*\))/gm , _replace ).split( this.config.tp ),
            _url ,
            _filePath;
        for( var i = _al.length; i--; ){
            if( i % 2 ){
                _al[ i ]    = _al[ i ].replace( /\s/gi , "" );
                tool.checkFileStatus( _al[ i ].replace( /[^\:]*src=['|"]([^'|^"]*)['|"].*/gi , "$1" ) , function( exists , filePath ){
                    if( !config.filePath.fetchUrl[ filePath ] ){
                        _url    = tool.getFileTs( filePath );
                        if( exists ){
                            _filePath   = Path.parse( filePath );
                            _url = tool.uglifyJs( Path.join( config.dir.srcDir , filePath ) , _filePath.dir + "/" + _filePath.name + "." );
                            _url = config.redirectOrigin + _url;
                        }
                        config.filePath.fetchUrl[ filePath ] = _url;
                    }
                    _al[ i ] = _al[ i ].replace( /(.*src=['|"])([^'|^"]*)(['|"].*)/gi , "$1" + config.filePath.fetchUrl[ filePath ] + "$3" );
                } );
            };
        };
        return _al.join( "" );
    }
1316336
function parseConfig(contents) {
    var config = {};

    contents = contents.replace(rSeajsConfig, function ($) {
        $.replace(rAlias, function (_, $1) {
            config.alias = evalConfig($1);
        });

        $.replace(rPaths, function (_, $1) {
            config.paths = evalConfig($1);
        });

        $.replace(rVars, function (_, $1) {
            config.vars = evalConfig($1);
        });

        return '';
    });

    return {
        contents: contents,
        config: config
    };
}
319489
function toObject(src, dest, options) {
  if (!utils.isObject(options)) {
    options = {};
  }

  var config = {};
  if (utils.isObject(dest)) {
    options = extend({}, options, dest);
    dest = null;
  }

  if (utils.isObject(src)) {
    config = src;
  }

  if (isValidSrc(src)) {
    config.src = src;
  } else if (Array.isArray(src)) {
    config = normalize(src);
  }

  if (typeof dest === 'string') {
    config.dest = dest;
  }

  if (options.hasOwnProperty('options')) {
    options = extend({}, options, options.options);
    delete options.options;
  }

  config.options = extend({}, config.options, options);
  return config;
}
516684
function(config) {

    config = config || extend(false, {}, defaults);

    /*--------------
       File Paths
    ---------------*/

    var
      configPath = this.getPath(),
      sourcePaths = {},
      outputPaths = {},
      folder
    ;

    // resolve paths (config location + base + path)
    for(folder in config.paths.source) {
      if(config.paths.source.hasOwnProperty(folder)) {
        sourcePaths[folder] = path.resolve(path.join(configPath, config.base, config.paths.source[folder]));
      }
    }
    for(folder in config.paths.output) {
      if(config.paths.output.hasOwnProperty(folder)) {
        outputPaths[folder] = path.resolve(path.join(configPath, config.base, config.paths.output[folder]));
      }
    }

    // set config paths to full paths
    config.paths.source = sourcePaths;
    config.paths.output = outputPaths;

    // resolve "clean" command path
    config.paths.clean = path.resolve( path.join(configPath, config.base, config.paths.clean) );

    /*--------------
        CSS URLs
    ---------------*/

    // determine asset paths in css by finding relative path between themes and output
    // force forward slashes

    config.paths.assets = {
      source       : '../../themes', // source asset path is always the same
      uncompressed : './' + path.relative(config.paths.output.uncompressed, config.paths.output.themes).replace(/\\/g, '/'),
      compressed   : './' + path.relative(config.paths.output.compressed, config.paths.output.themes).replace(/\\/g, '/'),
      packaged     : './' + path.relative(config.paths.output.packaged, config.paths.output.themes).replace(/\\/g, '/')
    };

    /*--------------
       Permission
    ---------------*/

    if(config.permission) {
      config.hasPermissions = true;
    }
    else {
      // pass blank object to avoid causing errors
      config.permission     = {};
      config.hasPermissions = false;
    }

    /*--------------
         Globs
    ---------------*/

    if(!config.globs) {
      config.globs = {};
    }

    // remove duplicates from component array
    if(config.components instanceof Array) {
      config.components = config.components.filter(function(component, index) {
        return config.components.indexOf(component) == index;
      });
    }

    // takes component object and creates file glob matching selected components
    config.globs.components = (typeof config.components == 'object')
      ? (config.components.length > 1)
        ? '{' + config.components.join(',') + '}'
        : config.components[0]
      : '{' + defaults.components.join(',') + '}'
    ;

    return config;

  }
200331
function normalizeOptions(config) {
  var alias = config.alias || "foreign";
  var type = config.type;

  //
  if ((0, _typeof3.default)(config.options) !== "object" || Array.isArray(config.options)) {
    throw new TypeError("Invalid options type for " + alias);
  }

  //
  var options = (0, _assign2.default)({}, config.options);

  if (type !== "arguments") {
    if (options.filename !== undefined) {
      throw new Error(alias + ".filename is only allowed as a root argument");
    }

    if (options.babelrc !== undefined) {
      throw new Error(alias + ".babelrc is only allowed as a root argument");
    }
  }

  if (type === "preset") {
    if (options.only !== undefined) {
      throw new Error(alias + ".only is not supported in a preset");
    }
    if (options.ignore !== undefined) {
      throw new Error(alias + ".ignore is not supported in a preset");
    }
    if (options.extends !== undefined) {
      throw new Error(alias + ".extends is not supported in a preset");
    }
    if (options.env !== undefined) {
      throw new Error(alias + ".env is not supported in a preset");
    }
  }

  if (options.sourceMap !== undefined) {
    if (options.sourceMaps !== undefined) {
      throw new Error("Both " + alias + ".sourceMap and .sourceMaps have been set");
    }

    options.sourceMaps = options.sourceMap;
    delete options.sourceMap;
  }

  for (var key in options) {
    // check for an unknown option
    if (!optionNames.has(key)) {
      if (_removed2.default[key]) {
        throw new ReferenceError("Using removed Babel 5 option: " + alias + "." + key + " - " + _removed2.default[key].message);
      } else {
        // eslint-disable-next-line max-len
        var unknownOptErr = "Unknown option: " + alias + "." + key + ". Check out http://babeljs.io/docs/usage/options/ for more information about options.";

        throw new ReferenceError(unknownOptErr);
      }
    }
  }

  if (options.parserOpts && typeof options.parserOpts.parser === "string") {
    options.parserOpts = (0, _assign2.default)({}, options.parserOpts);
    options.parserOpts.parser = (0, _files.loadParser)(options.parserOpts.parser, config.dirname).value;
  }

  if (options.generatorOpts && typeof options.generatorOpts.generator === "string") {
    options.generatorOpts = (0, _assign2.default)({}, options.generatorOpts);
    options.generatorOpts.generator = (0, _files.loadGenerator)(options.generatorOpts.generator, config.dirname).value;
  }

  delete options.passPerPreset;
  delete options.plugins;
  delete options.presets;

  return options;
}
1130733
function resolveRef(schemaObj, resolvedValues) {
            // the array store referenced value
            var refVal = schemaObj.refVal;
            // the map store full ref id and index of the referenced value in refVal
            // example: { 'test#definitions/option' : 1, 'test#definitions/repo' : 2 }
            var refs = schemaObj.refs;
            // the map to store schema value with sub reference
            var subRefs = {};

            _.forEach(refs, function (index, refId) {
                // if reference id already resolved then continue the loop
                if (refId in resolvedValues) {
                    return true; // continue
                }

                var refValue = refVal[index];
                // if no further nested reference, add to resolved map
                if (_.isEmpty(refValue.refs)) {
                    resolvedValues[refId] = refValue;
                    return true;
                }

                // add schema value with sub reference to map to resolve later
                subRefs[refId] = refValue;
            });

            // resolve sub reference recursively
            _.forEach(subRefs, function (subRef, refId) {
                resolvedValues[refId] = 1;
                resolvedValues[refId] = resolveRef(subRef, resolvedValues);
            });

            return schemaObj.schema;
        }