<commit_before>/**
 * Copyright 2013 Kitware Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

module.exports = function (grunt) {
    var apiRoot;
    var staticRoot;
    var fs = require('fs');
    var jade = require('jade');
    var path = require('path');
    require('colors');

    var defaultTasks = ['stylus', 'build-js'];

    // Pass a "--env=<value>" argument to grunt. Default value is "dev".
    var environment = grunt.option('env') || 'dev';
    var debugJs = grunt.option('debug-js') || false;

    var uglifyOptions = {
        sourceMap: environment === 'dev',
        sourceMapIncludeSources: true,
        report: 'min',
    };

    if (debugJs) {
        console.log('Building JS in debug mode'.yellow);
        uglifyOptions.beautify = false;
        uglifyOptions.mangle = false;
        uglifyOptions.compress = false;
    } else {
        uglifyOptions.beautify = {
            ascii_only: true
        };
    }

    var setServerConfig = function (err, stdout, stderr, callback) {
        if (err) {
            grunt.fail.fatal('config_parse failed on local.server.cfg: ' + stderr);
        }
        try {
            var cfg = JSON.parse(stdout);
            apiRoot = ((cfg.server && cfg.server.api_root) || '/api/v1').replace(/\"/g, "");
            staticRoot = ((cfg.server && cfg.server.static_root) || '/static').replace(/\"/g, "");
            grunt.config.set('serverConfig', {
                staticRoot: staticRoot,
                apiRoot: apiRoot
            });
            console.log('Static root: ' + staticRoot.bold);
            console.log('API root: ' + apiRoot.bold);
        }
        catch (e) {
            grunt.warn('Invalid json from config_parse: ' + stdout);
        }
        callback();
    };

    // Returns a json string containing information from the current git repository.
    var versionInfoObject = function () {<commit_msg>When the --debug-js option is specified with Grunt, beautify the results.<commit_after>/**
 * Copyright 2013 Kitware Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

module.exports = function (grunt) {
    var apiRoot;
    var staticRoot;
    var fs = require('fs');
    var jade = require('jade');
    var path = require('path');
    require('colors');

    var defaultTasks = ['stylus', 'build-js'];

    // Pass a "--env=<value>" argument to grunt. Default value is "dev".
    var environment = grunt.option('env') || 'dev';
    var debugJs = grunt.option('debug-js') || false;

    var uglifyOptions = {
        sourceMap: environment === 'dev',
        sourceMapIncludeSources: true,
        report: 'min',
    };

    if (debugJs) {
        console.log('Building JS in debug mode'.yellow);
        uglifyOptions.beautify = {
            beautify: true,
            ascii_only: true
        };
        uglifyOptions.mangle = false;
        uglifyOptions.compress = false;
    } else {
        uglifyOptions.beautify = {
            ascii_only: true
        };
    }

    var setServerConfig = function (err, stdout, stderr, callback) {
        if (err) {
            grunt.fail.fatal('config_parse failed on local.server.cfg: ' + stderr);
        }
        try {
            var cfg = JSON.parse(stdout);
            apiRoot = ((cfg.server && cfg.server.api_root) || '/api/v1').replace(/\"/g, "");
            staticRoot = ((cfg.server && cfg.server.static_root) || '/static').replace(/\"/g, "");
            grunt.config.set('serverConfig', {
                staticRoot: staticRoot,
                apiRoot: apiRoot
            });
            console.log('Static root: ' + staticRoot.bold);
            console.log('API root: ' + apiRoot.bold);
        }
        catch (e) {
            grunt.warn('Invalid json from config_parse: ' + stdout);
        }
        callback();
    };

    // Returns a json string containing information from the current git repository.
    var versionInfoObject = function () {
{'fraction_non_alphanumeric': 0.12421606311956301, 'fraction_numerical': 0.003641513251062108, 'mean_word_length': 2.3092369477911645, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7407214', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1367, 'n_words': 427}