/* environment functions
329766
protected function makeOutputBlock($type, $selectors = null)
    {
        $b = new stdclass();
        $b->lines = array();
        $b->children = array();
        $b->selectors = $selectors;
        $b->type = $type;
        $b->parent = $this->scope;

        return $b;
    }
1173154
function init (spec, defs, envs) {
  for (var key in spec || {}) {
    if (spec[key].def) defs[key] = spec[key].def
    if (has(spec[key].env)) envs[key] = get(spec[key].env)
  }
}
1270061
function setEnv(env) {
  home.initHomeDir();
  const envFile = path.join(home.getHomePath(), FILE_ENV);
  const envData = {
    env,
  };
  debug('set fie env data : %o', envData);
  debug('set fie to : %s', envFile);
  cacheEnv = null;
  fs.outputJsonSync(envFile, envData);
}
625023
@Override
    public void buildEnvironment(Run<?,?> build, EnvVars env) {
        env.put(name,originalFileName);
    }
242758
async function installPackages(environment) {
	const cwdBefore = process.cwd();
	await buildUnreleasedPackages();
	process.chdir(path.resolve(__dirname, '../environments', environment));
	console.log('🗑️  Removing packages for ' + environment);
	await rimrafAsync('package-lock.json');
	await rimrafAsync('node_modules');

	console.log('💿  Installing packages for ' + environment);
	await execAsync('npm install');
	process.chdir(cwdBefore);
}
596101
function replace_env_values(val_in) {
  if (!val_in)
    return ""

  let val_out = val_in

  const matches = val_in.match(/\$\w+/g)
    
  if (matches)
    matches.forEach(env => {
      const value = process.env[env.substring(1, env.length)]
    val_out = value.replace(new RegExp(`${env}`, "g"), value) // eslint-disable-line
    })

  return val_out
}
566469
function( name, testEnvironment, executeNow ) {
		var module, moduleFns;
		var currentModule = config.currentModule;

		if ( arguments.length === 2 ) {
			if ( testEnvironment instanceof Function ) {
				executeNow = testEnvironment;
				testEnvironment = undefined;
			}
		}

		// DEPRECATED: handles setup/teardown functions,
		// beforeEach and afterEach should be used instead
		if ( testEnvironment && testEnvironment.setup ) {
			testEnvironment.beforeEach = testEnvironment.setup;
			delete testEnvironment.setup;
		}
		if ( testEnvironment && testEnvironment.teardown ) {
			testEnvironment.afterEach = testEnvironment.teardown;
			delete testEnvironment.teardown;
		}

		module = createModule();

		moduleFns = {
			beforeEach: setHook( module, "beforeEach" ),
			afterEach: setHook( module, "afterEach" )
		};

		if ( executeNow instanceof Function ) {
			config.moduleStack.push( module );
			setCurrentModule( module );
			executeNow.call( module.testEnvironment, moduleFns );
			config.moduleStack.pop();
			module = module.parentModule || currentModule;
		}

		setCurrentModule( module );

		function createModule() {
			var parentModule = config.moduleStack.length ?
				config.moduleStack.slice( -1 )[ 0 ] : null;
			var moduleName = parentModule !== null ?
				[ parentModule.name, name ].join( " > " ) : name;
			var module = {
				name: moduleName,
				parentModule: parentModule,
				tests: []
			};

			var env = {};
			if ( parentModule ) {
				extend( env, parentModule.testEnvironment );
				delete env.beforeEach;
				delete env.afterEach;
			}
			extend( env, testEnvironment );
			module.testEnvironment = env;

			config.modules.push( module );
			return module;
		}

		function setCurrentModule( module ) {
			config.currentModule = module;
		}

	}
1210847
async function setEnv(service) {
  return new Promise((resolve) => {
    process.env[service.env] = `http://localhost:${service.port}`;
    resolve();
  });
}
814109
function func(schema, defaults, options) {
  if (kindOf(schema) !== 'function') {
    if (process.env.NODE_ENV !== 'production') {
      throw new Error(
        `Function structs must be defined as a function, but you passed: ${schema}`
      )
    } else {
      throw new Error(`Invalid schema: ${schema}`)
    }
  }

  const name = 'function'
  const type = '<function>'
  const validate = (value = resolveDefaults(defaults), data) => {
    const result = schema(value, data)
    let failure = { path: [], reason: null }
    let isValid

    switch (kindOf(result)) {
      case 'boolean': {
        isValid = result
        break
      }
      case 'string': {
        isValid = false
        failure.reason = result
        break
      }
      case 'object': {
        isValid = false
        failure = { ...failure, ...result }
        break
      }
      default: {
        if (process.env.NODE_ENV !== 'production') {
          throw new Error(
            `Validator functions must return a boolean, an error reason string or an error reason object, but you passed: ${schema}`
          )
        } else {
          throw new Error(`Invalid result: ${result}`)
        }
      }
    }

    return isValid
      ? [undefined, value]
      : [{ type, value, data: value, ...failure }]
  }

  return new Kind(name, type, validate)
}
1264741
function envOrSource(env, source) {
    function getKey(keyName) {
        return env[keyName] || source[keyName];
    }
    return getKey;
}
1370522
function logSome(env = 'dev', level = 'none') {
  let levelNum = 3
  const theme = {
    normal: '#92e6e6',
    error: '#ff5335',
    info: '#2994b2',
    warn: '#ffb400'
  }
  const setLevel = level => {
    switch (level) {
      case 'error':
        levelNum = 1
        break
      case 'warn':
        levelNum = 2
        break
      case 'info':
        levelNum = 3
        break
      default:
        levelNum = (env === 'development' || env === 'dev') ? 3 : 1
        break
    }
  }
  const getStyle = color => `color:${color || '#8b80f9'};font-weight:bold;`
  const isLogEnable = (opts, force, env) => {
    if (opts.level) {
      return force
    } else {
      return force || env === 'development' || env === 'dev'
    }
  }
  const logger = (info, force, opts = {}) => {
    if (isLogEnable(opts, force, env)) {
      if (opts.level && info instanceof Array && info.length === 2) {
        console.log('%c%s%o', getStyle(opts.color), `${info[0]} `, info[1])
      } else if (typeof info !== 'object' && typeof info !== 'function') {
        console.log('%c' + info, getStyle(opts.color))
      } else {
        console.log('%c%s%o', getStyle(opts.color), `${opts.level || 'log'} `, info)
      }
    }
  }
  logger.info = (info, extra) => {
    if (extra) info = [info, extra]
    logger(info, levelNum >= 3, { color: theme.info, level: 'info' })
  }
  logger.warn = (info, extra) => {
    if (extra) info = [info, extra]
    logger(info, levelNum >= 2, { color: theme.warn, level: 'warn' })
  }
  logger.error = (info, extra) => {
    if (extra) info = [info, extra]
    logger(info, levelNum >= 1, { color: theme.error, level: 'error' })
  }
  logger.setLevel = setLevel
  logger.toString = logger.valueOf = fstr('logger')

  setLevel(level)
  return logger
}
1062488
function getMachineEnv(machine) {
  var child = require('child_process');
  var result = child.spawnSync('docker-machine', ['env', machine]);

  if (result.status === 0) {
    var str = result.stdout.toString();
    var expr = str
      .replace(new RegExp('export ', 'g'), 'envs.')
      .split('\n')
      .filter(function (line) {
        return line[0] !== '#';
      }).join(';')

    var envs = {};
    eval(expr);
    return envs;
  } else {
    throw Error(result.stderr)
  }
}
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;
  });
}
825767
function setEnvironments (config) {
  environments.environments = config.environments || {}
  environments.envId = getEnvId(config)
  environments.ENVID = environments.envId ? environments.envId.toUpperCase() : undefined
  environments.environmentTypes = environments.environments.static || keys(config)
  environments.environmentType = _.includes(environments.environmentTypes, environments.envId) ? environments.envId : environments.environments.default
}
66628
function (env) {
        var css = [],      // The CSS output
            rules = [],    // node.Rule instances
           _rules = [],    //
            rulesets = [], // node.Ruleset instances
            selector,      // The fully rendered selector
            debugInfo,     // Line number debugging
            rule;

        // Compile rules and rulesets
        for (var i = 0; i < this.rules.length; i++) {
            rule = this.rules[i];

            if (rule.rules || (rule instanceof tree.Media)) {
                rulesets.push(rule.toCSS(env));
            } else if (rule instanceof tree.Directive) {
                var cssValue = rule.toCSS(env);
                // Output only the first @charset definition as such - convert the others
                // to comments in case debug is enabled
                if (rule.name === "@charset") {
                    // Only output the debug info together with subsequent @charset definitions
                    // a comment (or @media statement) before the actual @charset directive would
                    // be considered illegal css as it has to be on the first line
                    if (env.charset) {
                        if (rule.debugInfo) {
                            rulesets.push(tree.debugInfo(env, rule));
                            rulesets.push(new tree.Comment("/* "+cssValue.replace(/\n/g, "")+" */\n").toCSS(env));
                        }
                        continue;
                    }
                    env.charset = true;
                }
                rulesets.push(cssValue);
            } else if (rule instanceof tree.Comment) {
                if (!rule.silent) {
                    if (this.root) {
                        rulesets.push(rule.toCSS(env));
                    } else {
                        rules.push(rule.toCSS(env));
                    }
                }
            } else {
                if (rule.toCSS && !rule.variable) {
                    if (this.firstRoot && rule instanceof tree.Rule) {
                        throw { message: "properties must be inside selector blocks, they cannot be in the root.",
                            index: rule.index, filename: rule.currentFileInfo ? rule.currentFileInfo.filename : null};
                    }
                    rules.push(rule.toCSS(env));
                } else if (rule.value && !rule.variable) {
                    rules.push(rule.value.toString());
                }
            }
        } 

        // Remove last semicolon
        if (env.compress && rules.length) {
            rule = rules[rules.length - 1];
            if (rule.charAt(rule.length - 1) === ';') {
                rules[rules.length - 1] = rule.substring(0, rule.length - 1);
            }
        }

        rulesets = rulesets.join('');

        // If this is the root node, we don't render
        // a selector, or {}.
        // Otherwise, only output if this ruleset has rules.
        if (this.root) {
            css.push(rules.join(env.compress ? '' : '\n'));
        } else {
            if (rules.length > 0) {
                debugInfo = tree.debugInfo(env, this);
                selector = this.paths.map(function (p) {
                    return p.map(function (s) {
                        return s.toCSS(env);
                    }).join('').trim();
                }).join(env.compress ? ',' : ',\n');

                // Remove duplicates
                for (var i = rules.length - 1; i >= 0; i--) {
                    if (rules[i].slice(0, 2) === "/*" ||  _rules.indexOf(rules[i]) === -1) {
                        _rules.unshift(rules[i]);
                    }
                }
                rules = _rules;

                css.push(debugInfo + selector + 
                        (env.compress ? '{' : ' {\n  ') +
                        rules.join(env.compress ? '' : '\n  ') +
                        (env.compress ? '}' : '\n}\n'));
            }
        }
        css.push(rulesets);

        return css.join('')  + (env.compress ? '\n' : '');
    }
33070
function validateEnvironment(environment, envContext, source = null) {

    // not having an environment is ok
    if (!environment) {
        return;
    }

    Object.keys(environment).forEach(env => {
        if (!envContext.get(env)) {
            const message = `${source}:\n\tEnvironment key "${env}" is unknown\n`;

            throw new Error(message);
        }
    });
}
927660
function env() { //this gets attached to fnoc object
  var currentEnv = process.env.NODE_ENV || 'development'
    , envObj = {};

  for (var fileName in this) {
    if (this.hasOwnProperty(fileName)) {
      envObj[fileName] = this[fileName];
      if (this[fileName][currentEnv]) {
        envObj[fileName] = this[fileName][currentEnv];
      }
    }
  }

  return envObj;
}