<commit_before>/*jshint esnext:true*/
/*globals module:true, require:true, process:true*/

/*
 * Grunt Task File
 * ---------------
 *
 * Task: S3
 * Description: Move files to and from s3
 * Dependencies: knox, async, underscore.deferred
 *
 */

module.exports = function (grunt) {

  const _ = require('underscore');
  const path = require('path');
  const s3 = require('./lib/s3').init(grunt);

  /**
   * Grunt aliases.
   */
  var log = grunt.log;

  /**
   * Transfer files to/from s3.
   *
   * Uses global s3 grunt config.
   */
  grunt.registerTask('s3', 'Publishes files to s3.', function () {
    var done = this.async();
    var config = _.defaults(s3.getConfig(), {
      upload: [],
      download: [],
      del: [],
      copy: []
    });

    var transfers = [];

    config.upload.forEach(function(upload) {
      // Expand list of files to upload.
      var files = grunt.file.expandFiles(upload.src);

      files.forEach(function(file) {
        file = path.resolve(file);
        upload.src = path.resolve(grunt.template.process(upload.src));

        // If there is only 1 file and it matches the original file wildcard,
        // we know this is a single file transfer. Otherwise, we need to build
        // the destination.
        var dest;
        if (files.length === 1 && file === upload.src) {
          dest = upload.dest;
        }
        else {
          if (upload.rel) {
            dest = path.join(upload.dest, path.relative(grunt.file.expandDirs(upload.rel)[0], file));
          }
          else {
            dest = path.join(upload.dest, path.basename(file));
          }
        }

        transfers.push(s3.upload(file, dest, upload));
      });
    });

    config.download.forEach(function(download) {
      transfers.push(s3.download(download.src, download.dest, download));
    });

    config.del.forEach(function(del) {
      transfers.push(s3.del(del.src, del));
    });

    config.copy.forEach(function(copy) {<commit_msg>Add template support for s3.upload.<commit_after>/*jshint esnext:true*/
/*globals module:true, require:true, process:true*/

/*
 * Grunt Task File
 * ---------------
 *
 * Task: S3
 * Description: Move files to and from s3
 * Dependencies: knox, async, underscore.deferred
 *
 */

module.exports = function (grunt) {

  const _ = require('underscore');
  const path = require('path');
  const s3 = require('./lib/s3').init(grunt);

  /**
   * Grunt aliases.
   */
  var log = grunt.log;

  /**
   * Transfer files to/from s3.
   *
   * Uses global s3 grunt config.
   */
  grunt.registerTask('s3', 'Publishes files to s3.', function () {
    var done = this.async();
    var config = _.defaults(s3.getConfig(), {
      upload: [],
      download: [],
      del: [],
      copy: []
    });

    var transfers = [];

    config.upload.forEach(function(upload) {
      // Expand list of files to upload.
      var files = grunt.file.expandFiles(upload.src),
          destPath = grunt.template.process(upload.dest);

      files.forEach(function(file) {
        file = path.resolve(file);
        upload.src = path.resolve(grunt.template.process(upload.src));

        // If there is only 1 file and it matches the original file wildcard,
        // we know this is a single file transfer. Otherwise, we need to build
        // the destination.
        var dest;
        if (files.length === 1 && file === upload.src) {
          dest = destPath;
        }
        else {
          if (upload.rel) {
            dest = path.join(destPath, path.relative(grunt.file.expandDirs(upload.rel)[0], file));
          }
          else {
            dest = path.join(destPath, path.basename(file));
          }
        }

        transfers.push(s3.upload(file, dest, upload));
      });
    });

    config.download.forEach(function(download) {
      transfers.push(s3.download(download.src, download.dest, download));
    });

    config.del.forEach(function(del) {
      transfers.push(s3.del(del.src, del));
    });

    config.copy.forEach(function(copy) {
{'fraction_non_alphanumeric': 0.15403726708074533, 'fraction_numerical': 0.007701863354037267, 'mean_word_length': 2.2156549520766773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6288363', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1236, 'n_words': 284}