<commit_before>/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Authors <NAME> @simenbrekken, <NAME> @einarlove
*/

"use strict";

const DefinePlugin = require("./DefinePlugin");

class EnvironmentPlugin {
	constructor(keys) {
		this.defaultValues = {};

		if(Array.isArray(keys)) {
			this.keys = keys;
		} else if(keys && typeof keys === "object") {
			this.keys = Object.keys(keys);
			this.defaultValues = keys;
		} else {
			this.keys = Array.prototype.slice.call(arguments);
		}
	}

	apply(compiler) {
		const definitions = this.keys.reduce(function(defs, key) {
			const value = process.env[key] || this.defaultValues[key];

			if(value === undefined) {
				compiler.plugin("this-compilation", function(compilation) {
					const error = new Error(
						'EnvironmentPlugin - ' + key + ' environment variable is undefined. \n\n' +
						'You can pass an object with default values to suppress this warning. \n' +
						'See http://webpack.github.io/docs/list-of-plugins.html#environmentplugin for example.'
					);

					error.name = "EnvVariableNotDefinedError";
					compilation.warnings.push(error);
				});
			}

			defs["process.env." + key] = typeof value === 'undefined' ? 'undefined' : JSON.stringify(value);

			return defs;
		}.bind(this), {});

		compiler.apply(new DefinePlugin(definitions));
	}
}

module.exports = EnvironmentPlugin;<commit_msg>Use double quotes<commit_after>/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Authors <NAME> @simenbrekken, <NAME> @einarlove
*/

"use strict";

const DefinePlugin = require("./DefinePlugin");

class EnvironmentPlugin {
	constructor(keys) {
		this.defaultValues = {};

		if(Array.isArray(keys)) {
			this.keys = keys;
		} else if(keys && typeof keys === "object") {
			this.keys = Object.keys(keys);
			this.defaultValues = keys;
		} else {
			this.keys = Array.prototype.slice.call(arguments);
		}
	}

	apply(compiler) {
		const definitions = this.keys.reduce(function(defs, key) {
			const value = process.env[key] || this.defaultValues[key];

			if(value === undefined) {
				compiler.plugin("this-compilation", function(compilation) {
					const error = new Error(
						"EnvironmentPlugin - " + key + " environment variable is undefined. \n\n" +
						"You can pass an object with default values to suppress this warning. \n" +
						"See http://webpack.github.io/docs/list-of-plugins.html#environmentplugin for example."
					);

					error.name = "EnvVariableNotDefinedError";
					compilation.warnings.push(error);
				});
			}

			defs["process.env." + key] = value === undefined ? "undefined" : JSON.stringify(value);

			return defs;
		}.bind(this), {});

		compiler.apply(new DefinePlugin(definitions));
	}
}

module.exports = EnvironmentPlugin;
{'fraction_non_alphanumeric': 0.15139442231075698, 'fraction_numerical': 0.0, 'mean_word_length': 3.634228187919463, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '205090', 'n_tokens_mistral': 998, 'n_tokens_neox': 856, 'n_words': 182}