<commit_before>var path = require("path");
var param = require("../core/params_analyze.js");
var child_process = require("child_process");
var globals = require("../core/globals");
var create_file_list = require("./create_file_list.js")
var file = require("../core/file.js");

/**
 * Constructs a new ClosureCompiler instance.
 * @exports ClosureCompiler
 * @class Closure Compiler binding.
 * @param {Object.<string,*>=} options Compilation options
 * @constructor
 */
var ClosureCompiler = function (options) {

    /**
     * Compilation options.
     * @type {Object.<string, *>}
     */
    this.options = typeof options == 'object' ? options : {};
    try {
        Object.keys(this.options);
    } catch (e) {
        this.options = {};
    }
};

/**
 * Validates an option.
 * @param {string} name Option name
 * @param {string} actual Actual value
 * @param {Array} expected Expected values
 * @throw {Error} If the option is invalid
 * @return {string} Validated option
 * @private
 */
ClosureCompiler._assertOption = function (name, actual, expected) {
    if (expected.indexOf(actual) < 0) {
        throw("Illegal " + name + " value: " + actual + " (" + expected + " expected)");
    }
};

/**
 * Java extension, e.g. '.exe' on windows.
 * @type {string}
 * @expose
 */
ClosureCompiler.JAVA_EXT = process.platform == 'win32' ? '.exe' : '';

/**
 * Gets the path of the global java executable.
 * @return {string} Absolute path to or "java(.exe)" if not determinable
 * @expose
 */
ClosureCompiler.getGlobalJava = function () {
    var java = null;

    if (process.env["JAVA_HOME"]) {
        java = path.join(process.env["JAVA_HOME"], "bin", "java" + ClosureCompiler.JAVA_EXT);
        if (!file.exists(java)) {
            java = null;
        }
    }
    if (!java) {
        java = "java";
    }
    return java;
};

/**
 * Gets the path of the bundled java executable.
 * @return {string} Absolute path to "java(.exe)"
 * @expose
 */
ClosureCompiler.getBundledJava = function () {
    return path.normalize(path.join(__dirname, "jre", "bin", "java" + ClosureCompiler.JAVA_EXT));
};

/**
 * Tests if java is callable.
 * @param {string} java Path to java
 * @param {function(boolean, Error)} callback Callback function
 * @expose
 */
ClosureCompiler.testJava = function (java, callback) {
    child_process.exec('"' + java + '" -version', {}, function (error, stdout, stderr) {
        stderr += "";
        if (stderr.indexOf("version \"1.7.") >= 0) {
            callback(true, null);
        } else if (stderr.indexOf("version \"") >= 0) {
            callback(false, new Error("Not Java 7"));
        } else {
            callback(false, error);
        }
    });
};<commit_msg>publish脚本支持Java 8<commit_after>var path = require("path");
var param = require("../core/params_analyze.js");
var child_process = require("child_process");
var globals = require("../core/globals");
var create_file_list = require("./create_file_list.js")
var file = require("../core/file.js");

/**
 * Constructs a new ClosureCompiler instance.
 * @exports ClosureCompiler
 * @class Closure Compiler binding.
 * @param {Object.<string,*>=} options Compilation options
 * @constructor
 */
var ClosureCompiler = function (options) {

    /**
     * Compilation options.
     * @type {Object.<string, *>}
     */
    this.options = typeof options == 'object' ? options : {};
    try {
        Object.keys(this.options);
    } catch (e) {
        this.options = {};
    }
};

/**
 * Validates an option.
 * @param {string} name Option name
 * @param {string} actual Actual value
 * @param {Array} expected Expected values
 * @throw {Error} If the option is invalid
 * @return {string} Validated option
 * @private
 */
ClosureCompiler._assertOption = function (name, actual, expected) {
    if (expected.indexOf(actual) < 0) {
        throw("Illegal " + name + " value: " + actual + " (" + expected + " expected)");
    }
};

/**
 * Java extension, e.g. '.exe' on windows.
 * @type {string}
 * @expose
 */
ClosureCompiler.JAVA_EXT = process.platform == 'win32' ? '.exe' : '';

/**
 * Gets the path of the global java executable.
 * @return {string} Absolute path to or "java(.exe)" if not determinable
 * @expose
 */
ClosureCompiler.getGlobalJava = function () {
    var java = null;

    if (process.env["JAVA_HOME"]) {
        java = path.join(process.env["JAVA_HOME"], "bin", "java" + ClosureCompiler.JAVA_EXT);
        if (!file.exists(java)) {
            java = null;
        }
    }
    if (!java) {
        java = "java";
    }
    return java;
};

/**
 * Gets the path of the bundled java executable.
 * @return {string} Absolute path to "java(.exe)"
 * @expose
 */
ClosureCompiler.getBundledJava = function () {
    return path.normalize(path.join(__dirname, "jre", "bin", "java" + ClosureCompiler.JAVA_EXT));
};

/**
 * Tests if java is callable.
 * @param {string} java Path to java
 * @param {function(boolean, Error)} callback Callback function
 * @expose
 */
ClosureCompiler.testJava = function (java, callback) {
    child_process.exec('"' + java + '" -version', {}, function (error, stdout, stderr) {
        stderr += "";
        if (stderr.indexOf("version \"1.7.") >= 0 || stderr.indexOf("version \"1.8.") >= 0) {
            callback(true, null);
        } else if (stderr.indexOf("version \"") >= 0) {
            callback(false, new Error("Not Java 7"));
        } else {
            callback(false, error);
        }
    });
};
{'fraction_non_alphanumeric': 0.16663604629799741, 'fraction_numerical': 0.0036744442403086534, 'mean_word_length': 2.9592727272727273, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2614834', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1671, 'n_words': 448}