{"size": 1289, "ext": "js", "max_stars_repo_path": "tasks/uncomment-it.js", "max_stars_repo_name": "stevemao/grunt-uncomment-it", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tasks/uncomment-it.js", "max_issues_repo_name": "stevemao/grunt-uncomment-it", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tasks/uncomment-it.js", "max_forks_repo_name": "stevemao/grunt-uncomment-it", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.2954545455, "max_line_length": 109, "alphanum_fraction": 0.6051202483}
'use strict';
var chalk = require('chalk');
var extname = require('path').extname;
var uncommentIt = require('uncomment-it');

module.exports = function(grunt) {
  grunt.registerMultiTask('uncommentIt', 'Uncomment html, js or css', function() {
    var files = this.files;
    var opts = this.options();

    files.forEach(function(file) {
      var fileSrc = file.src;
      var type = opts.type;

      if (fileSrc.length > 1) {
        grunt.log.warn('Only one src per dest is supported. The first file is used');
      }

      var src = fileSrc[0];
      var dest = file.dest || src;
      type = type || extname(src).replace('.', '');

      var data = grunt.file.read(src);
      var result = uncommentIt(data, type);

      var uncommentedCount = result.comments.length;

      if (uncommentedCount > 0) {
        result.comments.forEach(function(comment) {
          grunt.verbose.writeln(chalk.green(comment) + chalk.cyan('uncommented'));
        });

        grunt.verbose.writeln(dest + ': ' + chalk.green('✔ ') + uncommentedCount + ' comments uncommented.');
      }

      grunt.file.write(dest, result.data);
    });

    var tally = files.length;
    grunt.log.write('Processed ' + chalk.cyan(tally) + (tally === 1 ? ' file' : ' files'));
    grunt.log.writeln();
  });
};
