<commit_before>// Copyright 2002-2015, University of Colorado Boulder

var Jimp = require( 'jimp' );

/**
 * Generate 128x84 and 600x394 thumbnails of the sim's screenshot in assets
 *
 * @param grunt
 * @param projectName of the project (repository)
 * @param width
 * @param height
 */
module.exports = function( grunt, projectName, width, height ) {
  'use strict';

  var fullResImageName = 'assets/' + projectName + '-screenshot.png';
  var destinationFile = 'build/' + projectName + '-' + width + '.png';

  if ( !grunt.file.exists( fullResImageName ) ) {
    console.log( 'no image file exists: ' + fullResImageName + '. Not running task: generate-thumbnails' );
    return;
  }

  if ( !grunt.file.exists( 'build' ) ) {
    grunt.file.mkdir( 'build' );
  }

  var done = grunt.task.current.async();

  /* jshint -W031 */
  new Jimp( fullResImageName, function() {
    this.resize( width, height ).write( destinationFile, done );
  } );
};
<commit_msg>add @author to generateThumbnails, reenable jshint W031 and give explanation, see #113<commit_after>// Copyright 2002-2015, University of Colorado Boulder

/**
 * This grunt task generates 128x84 and 600x394 thumbnails of the sim's screenshot in assets.
 * Thumbnails are put in the build directory of the sim. If the directory doesn't exist, it is created.
 * New grunt tasks can easily be created to generate different sized images by passing this function
 * different heights and widths.
 *
 * @author <NAME>
 */

var Jimp = require( 'jimp' );

/**
 * @param grunt the grunt instance
 * @param projectName of the project (repository)
 * @param width of the resized image
 * @param height of the resized image
 */
module.exports = function( grunt, projectName, width, height ) {
  'use strict';

  var fullResImageName = 'assets/' + projectName + '-screenshot.png';
  var destinationFile = 'build/' + projectName + '-' + width + '.png';

  if ( !grunt.file.exists( fullResImageName ) ) {
    console.log( 'no image file exists: ' + fullResImageName + '. Not running task: generate-thumbnails' );
    return;
  }

  if ( !grunt.file.exists( 'build' ) ) {
    grunt.file.mkdir( 'build' );
  }

  var done = grunt.task.current.async();

  // W031 says "do not use new for side effects."
  // It is disabled here because Jimp takes a callback that does the image processing.
  /* jshint -W031 */
  new Jimp( fullResImageName, function() {
    this.resize( width, height ).write( destinationFile, done );
  } );
  /* jshint +W031 */
};

{'fraction_non_alphanumeric': 0.12715603690332933, 'fraction_numerical': 0.022462896109105495, 'mean_word_length': 3.4936936936936935, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7564162', 'n_tokens_mistral': 832, 'n_tokens_neox': 765, 'n_words': 264}