Merge app into ENV

@param {String} env
@param {String} app
@param {Object} conf
@param {Object} ENV
@param {Function} fn
506876
function mergeApp(env, app, conf, ENV, fn) {
  fetch(conf, 'apps', function(err, apps) {
    if (err) return fn(err);
    debug('# APP');
    debug(app);
    mergeConf(env, apps, app, ENV, fn);
  });
}
1173815
function(apps) {

  var filepath = getGlobalConfig().appRegistry;

  var tempFilepath = filepath + '.tmp';

  // Write to temp file.
  return Promise.fromNode(function(cb) {
    fs.writeFile(tempFilepath, JSON.stringify(apps), cb);
    log.debug(format('Setting app registry with %j', apps));
  })
  // Rename temp file to normal file.
  .then(function() {
    return Promise.fromNode(function(cb) {
      fs.rename(tempFilepath, filepath, cb);
    });
  });

}
316649
def get_app_env():
    
    app, env = None, get_env()
    if "app" in os.environ:
        app = os.environ["app"].lower()
        if ":" in app:
            app, env = os.environ["app"].split(":", 2)
            set_env(env)
    return app, env
1211374
function(app) {
  if (process.env.POMELO_LOGGER !== 'off') {
    var env = app.get(Constants.RESERVED.ENV);
    var originPath = path.join(app.getBase(), Constants.FILEPATH.LOG);
    var presentPath = path.join(app.getBase(), Constants.FILEPATH.CONFIG_DIR, env, path.basename(Constants.FILEPATH.LOG));
    if(fs.existsSync(originPath)) {
      log.configure(app, originPath);
    } else if(fs.existsSync(presentPath)) {
      log.configure(app, presentPath);
    } else {
      logger.error('logger file path configuration is error.');
    }
  }
}
1190766
function config (args) {
    // iterate over args merging configuration to either the module or the
    // global configuration
    _.each(args, (val, key) => {
        // configuration to modify
        var config
        // create new object to merge into config
        var merge = {}
        // set key and value to merge
        merge[key] = val
        // if this is a global config option then modify global config
        if (key in defaultGlobalConfig) {
            // merge args over config with custom handler to merge arrays
            _.mergeWith(immutableApp, merge, mergeArrays)
        }
        // if this is module config then set config on module instance
        else if (key in defaultModuleConfig) {
            // merge args over config with custom handler to merge arrays
            _.mergeWith(this, merge, mergeArrays)
        }
        // throw error on invalid configuration option
        else {
            throw new Error('invalid config option '+key)
        }
    })
    // return module
    return this
}
509679
function mergeDefaultConfig(opts) {

    let devModeEnabled = isDevelopMode();
    let debugModeEnabled = isDebugMode();

    console.log('------------------------------------------------------------------------------------');
    console.log(`Executing build for ` + (devModeEnabled ? ENV_DEVELOPMENT : ENV_PROD));
    console.log('------------------------------------------------------------------------------------');

    let config = {

        metadata: {
            ENV: devModeEnabled ? ENV_DEVELOPMENT : ENV_PROD
        },
        devtool: 'source-map',
        debug: debugModeEnabled,

        entry: {},

        output: {
            filename: devModeEnabled ? '[name].bundle.js' : '[name].[chunkhash].bundle.js',
            sourceMapFilename: devModeEnabled ? '[name].bundle.map' : '[name].[chunkhash].bundle.map',
            chunkFilename: devModeEnabled ? '[id].chunk.js' : '[id].[chunkhash].chunk.js'
        },

        resolve: {
            cache: false,
            extensions: ['', '.ts', '.tsx', '.js', '.json', '.css', '.html']
        },

        module: {
            preLoaders: [],
            loaders: []
        },

        plugins: [],

        // we need this due to problems with es6-shim
        node: {
            global: 'window',
            progress: false,
            crypto: 'empty',
            module: false,
            clearImmediate: false,
            setImmediate: false
        }
    };

    if (debugModeEnabled) {
        console.log(merge(config, opts));
        console.log('------------------------------------------------------------------------------------');
    }

    return merge(config, opts);
}
347267
func Env(app *Manifest, process *Process) map[string]string {
	return merge(app.Env, process.Env)
}
150044
function loadConfig(config, env) {
    env = env || ''; // default as empty
    //resolve for absolute path of config file
    let configPath = path.resolve(app.path, 'app/config', env, config);
    //path is exist return the path else give a false flag

    let pacc = Utilities.tryInvoke(function () {
        return require(configPath);
    });
    return pacc;
}
152493
function injectEnvs(node) {
    switch (node.type) {
        case 'Program':
            node.$env = new Map;
            node.$depth = 0;
            break;
        case 'FunctionExpression':
            node.$env = new Map;
            node.$depth = 1 + getEnclosingScope(node.$parent).$depth;
            if (node.id) {
                node.$env.put(node.id.name, node.id)
            }
            for (var i=0; i<node.params.length; i++) {
                node.$env.put(node.params[i].name, node.params[i])
            }
            node.$env.put('arguments', node)
            break;
        case 'FunctionDeclaration':
            var parent = getEnclosingFunction(node.$parent); // note: use getEnclosingFunction, because fun decls are lifted outside catch clauses
            node.$env = new Map;
            node.$depth = 1 + parent.$depth;
            parent.$env.put(node.id.name, node.id)
            for (var i=0; i<node.params.length; i++) {
                node.$env.put(node.params[i].name, node.params[i])
            }
            node.$env.put('arguments', node)
            break;
        case 'CatchClause':
            node.$env = new Map;
            node.$env.put(node.param.name, node.param)
            node.$depth = 1 + getEnclosingScope(node.$parent).$depth;
            break;
        case 'VariableDeclarator':
            var parent = getEnclosingFunction(node) // note: use getEnclosingFunction, because vars ignore catch clauses
            parent.$env.put(node.id.name, node.id)
            break;
    }
    children(node).forEach(injectEnvs)
}
239899
function init(projectDir, argsOrName) {
  console.log('Setting up new React Native app in ' + projectDir);
  const env = yeoman.createEnv(
    undefined,
    undefined,
    new CreateSuppressingTerminalAdapter()
  );

  env.register(
    require.resolve(path.join(__dirname, '../generator')),
    'react:app'
  );

  // argv is for instance
  // ['node', 'react-native', 'init', 'AwesomeApp', '--verbose']
  // args should be ['AwesomeApp', '--verbose']
  const args = Array.isArray(argsOrName)
    ? argsOrName
    : [argsOrName].concat(process.argv.slice(4));

  const generator = env.create('react:app', {args: args});
  generator.destinationRoot(projectDir);
  generator.run();
}
999808
public static Environment merge(Environment env1, Environment env2) {
		final Environment mergedEnv = new Environment();

		// merge tables
		final Map<String, TableEntry> tables = new LinkedHashMap<>(env1.getTables());
		tables.putAll(env2.getTables());
		mergedEnv.tables = tables;

		// merge functions
		final Map<String, FunctionEntry> functions = new HashMap<>(env1.getFunctions());
		functions.putAll(env2.getFunctions());
		mergedEnv.functions = functions;

		// merge execution properties
		mergedEnv.execution = ExecutionEntry.merge(env1.getExecution(), env2.getExecution());

		// merge deployment properties
		mergedEnv.deployment = DeploymentEntry.merge(env1.getDeployment(), env2.getDeployment());

		return mergedEnv;
	}
1042840
protected function checkForSpecificEnvironmentFile($app)
    {
        if ($app->runningInConsole() && ($input = new ArgvInput)->hasParameterOption('--env')) {
            if ($this->setEnvironmentFilePath(
                $app, $app->environmentFile().'.'.$input->getParameterOption('--env')
            )) {
                return;
            }
        }

        if (! env('APP_ENV')) {
            return;
        }

        $this->setEnvironmentFilePath(
            $app, $app->environmentFile().'.'.env('APP_ENV')
        );
    }
1209003
function getEnvironment(opts) {
  if (opts.app) {
    // Merge app env over the process env and return.
    var processEnv = _.cloneDeep(process.env);
    var appEnv = opts.app.env.getEnv();
    return _.merge(processEnv, appEnv);
  } else {
    // Just use process env.
    return process.env;
  }
}
1086771
def setup_app(command, conf, vars):
    """"""
    load_environment(conf.global_conf, conf.local_conf)

    # Merge and minify JavaScript code
    input_file = config['js_tmpl']
    public_dir = config['pylons.paths']['static_files']
    output_file = os.path.join(public_dir, 'js', 'Studio', 'studio-all.js')
    _merge_js(input_file, public_dir, output_file)
    log.info('JavaScript successfully merged and minified in ' + output_file)

    # Load the models
    from studio.model import meta
    meta.metadata.bind = meta.engine

    filename = os.path.split(conf.filename)[-1]
    if filename == 'test.ini':
        # Permanently drop any existing tables
        log.info("Dropping existing tables...")
        meta.metadata.drop_all(checkfirst=True)

    # Create the tables if they aren't there already
    meta.metadata.create_all(checkfirst=True)

    # Create permissions
    # datastores permissions
    perm_create_update_datastores = model.Permission()
    perm_create_update_datastores.name = 'create_update_datastores'
    meta.Session.add(perm_create_update_datastores)
    perm_view_datastores = model.Permission()
    perm_view_datastores.name = 'view_datastores'
    meta.Session.add(perm_view_datastores)
    # datasources permissions
    perm_view_datasources = model.Permission()
    perm_view_datasources.name = 'view_datasources'
    meta.Session.add(perm_view_datasources)
    perm_create_datasources = model.Permission()
    perm_create_datasources.name = 'create_datasources'
    meta.Session.add(perm_create_datasources)
    # mapfiles permissions
    perm_create_update_mapfiles = model.Permission()
    perm_create_update_mapfiles.name = 'create_update_mapfiles'
    meta.Session.add(perm_create_update_mapfiles)
    perm_view_mapfiles = model.Permission()
    perm_view_mapfiles.name = 'view_mapfiles'
    meta.Session.add(perm_view_mapfiles)
    # layertemplates permissions
    perm_create_update_layertemplates = model.Permission()
    perm_create_update_layertemplates.name = 'create_update_layertemplates'
    meta.Session.add(perm_create_update_layertemplates)
    perm_view_layertemplates = model.Permission()
    perm_view_layertemplates.name = 'view_layertemplates'
    meta.Session.add(perm_view_layertemplates)

    # Create group admin
    admin_gp = model.Group()
    admin_gp.name = 'admin'
    admin_gp.permissions.append(perm_create_update_datastores)
    admin_gp.permissions.append(perm_view_datastores)
    admin_gp.permissions.append(perm_view_datasources)
    admin_gp.permissions.append(perm_create_datasources)
    admin_gp.permissions.append(perm_create_update_mapfiles)
    admin_gp.permissions.append(perm_view_mapfiles)
    admin_gp.permissions.append(perm_create_update_layertemplates)
    admin_gp.permissions.append(perm_view_layertemplates)
    meta.Session.add(admin_gp)

    # Create group enduser
    enduser_gp = model.Group()
    enduser_gp.name = 'enduser'
    enduser_gp.permissions.append(perm_view_datastores)
    enduser_gp.permissions.append(perm_view_datasources)
    enduser_gp.permissions.append(perm_create_update_mapfiles)
    enduser_gp.permissions.append(perm_view_mapfiles)
    enduser_gp.permissions.append(perm_create_update_layertemplates)
    enduser_gp.permissions.append(perm_view_layertemplates)
    meta.Session.add(enduser_gp)

    # Create user admin
    admin = model.User()
    admin.name = 'Admin'
    admin.login = 'admin'
    admin.password = config['admin_password']
    admin.groups.append(admin_gp)
    meta.Session.add(admin)

    if filename == 'test.ini':
        # create enduser user for test purpose only
        enduser = model.User()
        enduser.name = 'Test User'
        enduser.login = 'enduser'
        enduser.password = 'password'
        enduser.groups.append(enduser_gp)
        meta.Session.add(enduser)

    mfdir = config['mapfiles_dir']
    if not os.path.exists(mfdir):
        os.makedirs(mfdir, 0755)

    if 'default_datastore_postgis' in config:
        # Create default datastore
        datastore = model.DataStore('default (postgis)', 'postgis', config['default_datastore_postgis'])
        meta.Session.add(datastore)
        meta.Session.flush()

    if 'default_datastore_dir' in config:
        # Create default datastore
        datastore = model.DataStore('default (directory)', 'directory', config['default_datastore_dir'])
        meta.Session.add(datastore)
        meta.Session.flush()

        # Create dummy mapfile
        mapfile = create_default_mapfile()
        dict = mapfile.to_dict()
        ds = DataStore(datastore.ogrstring)
        dsources = ds.get_datasources()
        palette = QualitativePalette(len(dsources)).get_palette()
        for dss in dsources:
            if dss.type == 'RASTER':
                print "adding %s datasource"%dss.name
                l = _make_mapfile_layer(datastore.id,dss)
                if 'projection' in l:
                    dict['projection'] = l['projection']
                dict['layers'].append(l)
        for dss in dsources:
            if dss.type == 'POLYGON':
                print "adding %s datasource"%dss.name
                color = palette.pop(0)
                l = _make_mapfile_layer(datastore.id,dss)
                if 'projection' in l:
                    dict['projection'] = l['projection']
                l['classes'][0]['styles'][0]['color']=color
                dict['layers'].append(l)
        for dss in dsources:
            if dss.type == 'LINE':
                print "adding %s datasource"%dss.name
                color = palette.pop(0)
                l = _make_mapfile_layer(datastore.id,dss)
                if 'projection' in l:
                    dict['projection'] = l['projection']
                l['classes'][0]['styles'][0]['color']=color
                dict['layers'].append(l)
        for dss in dsources:
            if dss.type == 'POINT':
                print "adding %s datasource"%dss.name
                color = palette.pop(0)
                l = _make_mapfile_layer(datastore.id,dss)
                if 'projection' in l:
                    dict['projection'] = l['projection']
                l['classes'][0]['styles'][0]['color']=color
                dict['layers'].append(l)
        if 'projection' not in dict:
            dict['projection']="init=epsg:4326"
        mapfile.from_dict(dict)
        mapfile.to_file(os.path.join(config['mapfiles_dir'], 'dummy_mapfile.map'))

        # Create dummy_mapfile in db, owned by user 'admin'
        map = model.Map('dummy_mapfile', 'dummy_mapfile.map', 1)
        model.meta.Session.add(map)

    # Commit the new objects into the database
    meta.Session.commit()

    log.info("Data successfully set up")
962745
protected static DisConfCommonModel makeDisConfCommonModel(String app, String env, String version) {

        DisConfCommonModel disConfCommonModel = new DisConfCommonModel();

        // app
        if (!app.isEmpty()) {
            disConfCommonModel.setApp(app);
        } else {
            disConfCommonModel.setApp(DisClientConfig.getInstance().APP);
        }

        // env
        if (!env.isEmpty()) {
            disConfCommonModel.setEnv(env);
        } else {
            disConfCommonModel.setEnv(DisClientConfig.getInstance().ENV);
        }

        // version
        if (!version.isEmpty()) {
            disConfCommonModel.setVersion(version);
        } else {
            disConfCommonModel.setVersion(DisClientConfig.getInstance().VERSION);
        }

        return disConfCommonModel;
    }
1307973
function envPlugin(dynamicConfig, options) {
    var self = this;
    var separator;
    var whitelist;

    if (options && typeof options === "object") {
        separator = options.separator;
        whitelist = options.whitelist;
    }

    this(dynamicConfig).after("loadConfigFile", function (result) {
        self.override.result = merge(result, process.env, separator, whitelist);
    });
}
71506
function mergeAssets (
  parentVal,
  childVal,
  vm,
  key
) {
  const res = Object.create(parentVal || null)
  if (childVal) {
    process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm)
    return extend(res, childVal)
  }
  return res
}