<commit_before>/*
 * grunt-multiresize
 * https://github.com/jeduan/icons-yogome
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

'use strict';
var gm = require('gm'),
    async = require('async');

module.exports = function(grunt) {

  // Please see the Grunt documentation for more information regarding task
  // creation: http://gruntjs.com/creating-tasks

  grunt.registerMultiTask('multiresize', 'Allows to create multiple resized images from an image', function() {
    var done = this.async();

    async.each(this.files, function(f, next) {
      var src, i = 0;

      //Ignores all but first src file
      if (f.src.length >= 1) {
        src = f.src[0];
      } else {
        return next();
      }

      if (!grunt.file.exists(src)) {
        return next(new Error('Source file "'+ src +'" not found.'));
      }

      async.map(f.dest, function(dest, callback) {
        var size = f.destSizes[i++].split('x'),
            folder = dest.substr(0, dest.lastIndexOf('/'));

        if (! grunt.file.exists(folder)) {
          grunt.log.ok('Creating folder "' + folder + '".');
          grunt.file.mkdir(folder);
        }

        gm(src).thumb(size[0], size[1], dest, 90, function(err){
          if(err) { return callback(err); }
          grunt.log.ok('Created "' + dest + '".');
          callback(null);
        });

      }, next);

    }, function(err) {
      if(err) {
        grunt.log.error(err.message);
        return done(false);
      }
      done();
    });

  });

};
<commit_msg>Prevents error when only one dest is configured<commit_after>/*
 * grunt-multiresize
 * https://github.com/jeduan/icons-yogome
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

'use strict';
var gm = require('gm'),
    async = require('async');

module.exports = function(grunt) {

  // Please see the Grunt documentation for more information regarding task
  // creation: http://gruntjs.com/creating-tasks

  grunt.registerMultiTask('multiresize', 'Allows to create multiple resized images from an image', function() {
    var done = this.async();

    var toStr = Object.prototype.toString
    async.each(this.files, function(f, next) {
      var src, i = 0;

      //Ignores all but first src file
      if (f.src.length >= 1) {
        src = f.src[0];
      } else {
        return next();
      }

      if (!grunt.file.exists(src)) {
        return next(new Error('Source file "'+ src +'" not found.'));
      }

      if (toStr.call(f.dest) !== '[object Array]') {
        f.dest = [f.dest];
      }

      if (toStr.call(f.destSizes) !== '[object Array]') {
        f.destSizes = [f.destSizes];
      }

      async.map(f.dest, function(dest, callback) {
        var size = f.destSizes[i++].split('x'),
            folder = dest.substr(0, dest.lastIndexOf('/'));

        if (! grunt.file.exists(folder)) {
          grunt.log.ok('Creating folder "' + folder + '".');
          grunt.file.mkdir(folder);
        }

        gm(src).thumb(size[0], size[1], dest, 90, function(err){
          if(err) { return callback(err); }
          grunt.log.ok('Created "' + dest + '".');
          callback(null);
        });

      }, next);

    }, function(err) {
      if(err) {
        grunt.log.error(err.message);
        return done(false);
      }
      done();
    });

  });

};

{'fraction_non_alphanumeric': 0.16950672645739912, 'fraction_numerical': 0.007174887892376682, 'mean_word_length': 2.2173076923076924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '769898', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1065, 'n_words': 242}