<commit_before>/*
 * grunt-espower
 * https://github.com/twada/grunt-espower
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

var espower = require('espower'),
    esprima = require('esprima'),
    escodegen = require('escodegen'),
    fs = require('fs');

module.exports = function(grunt) {
    'use strict';

    grunt.registerMultiTask('espower', 'instrument power assert feature into code.', function() {
        // Merge task-specific and/or target-specific options with these defaults.
        var _ = grunt.util._,
            options = this.options(espower.defaultOptions());

        // Iterate over all specified file groups.
        this.files.forEach(function(f) {
            f.src.filter(function(filepath) {
                // Warn on and remove invalid source files (if nonull was set).
                if (!grunt.file.exists(filepath)) {
                    grunt.log.warn('Source file "' + filepath + '" not found.');
                    return false;
                } else {
                    return true;
                }
            }).forEach(function(filepath) {
                grunt.verbose.writeln('espower src: ' + f.src);
                var absPath = fs.realpathSync(filepath),
                    jsCode = fs.readFileSync(filepath, 'utf-8'),
                    jsAst = esprima.parse(jsCode, {tolerant: true, loc: true, range: true}),
                    espowerOptions = _.merge(options, {
                        path: absPath,
                        source: jsCode
                    }),
                    modifiedAst = espower(jsAst, espowerOptions);
                grunt.verbose.writeln('espower dest: ' + f.dest);
                grunt.file.write(f.dest, escodegen.generate(modifiedAst));
            });
        });
    });

};<commit_msg>Change logging point a bit later.<commit_after>/*
 * grunt-espower
 * https://github.com/twada/grunt-espower
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

var espower = require('espower'),
    esprima = require('esprima'),
    escodegen = require('escodegen'),
    fs = require('fs');

module.exports = function(grunt) {
    'use strict';

    grunt.registerMultiTask('espower', 'instrument power assert feature into code.', function() {
        // Merge task-specific and/or target-specific options with these defaults.
        var _ = grunt.util._,
            options = this.options(espower.defaultOptions());

        // Iterate over all specified file groups.
        this.files.forEach(function(f) {
            f.src.filter(function(filepath) {
                // Warn on and remove invalid source files (if nonull was set).
                if (!grunt.file.exists(filepath)) {
                    grunt.log.warn('Source file "' + filepath + '" not found.');
                    return false;
                } else {
                    return true;
                }
            }).forEach(function(filepath) {
                grunt.verbose.writeln('espower src: ' + f.src);
                var absPath = fs.realpathSync(filepath),
                    jsCode = fs.readFileSync(filepath, 'utf-8'),
                    jsAst = esprima.parse(jsCode, {tolerant: true, loc: true, range: true}),
                    espowerOptions = _.merge(options, {
                        path: absPath,
                        source: jsCode
                    }),
                    modifiedAst = espower(jsAst, espowerOptions);
                grunt.file.write(f.dest, escodegen.generate(modifiedAst));
                grunt.verbose.writeln('espower dest: ' + f.dest);
            });
        });
    });

};
{'fraction_non_alphanumeric': 0.12403740374037404, 'fraction_numerical': 0.0027502750275027505, 'mean_word_length': 1.7202692595362752, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3345030', 'n_tokens_mistral': 1022, 'n_tokens_neox': 973, 'n_words': 221}