<commit_before>/*
 * MIT License (MIT) - Copyright (c) 2014 <NAME>
 *
 * This file is part of <grunt-dock>.
 */
var fs = require('fs'),
    path = require('path'),
    tar = require('tar-stream'),
    tarfs = require('tar-fs'),
    concat = require('concat-stream'),
    zlib = require('zlib'),
    async = require('async'),
    utils = require('./utils');

/**
 * Build images.
 * Each image is a content associated with its tag name.
 * The content can be a regular file or whatever for Docker.
 * In case of a plain file, it will be tar + gz before sent
 * to Docker.
 *
 * @param  {Object}   grunt   The Grunt Object
 * @param  {Object}   docker  The Dockerode connection
 * @param  {Object}   options The Grunt options
 * @param  {Function} done    The done function to call when finished
 * @param  {String}   tag     The image tag to work with or null
 */
var buildCommands = function(grunt, docker, options, done, tag) {

  // Build image with tag and its data/options.
  // Call callback when done or error.
  var build = function(data, options, callback) {
    grunt.log.subhead('Building image [' + options.t + ']');

    docker.buildImage(data, options, function(err, stream) {

      if (err) {
        return callback(err);
      }

      stream.setEncoding('utf8');

      stream.on('data', function(data) {
        var jsonData = JSON.parse(data);
        jsonData.stream && grunt.log.write(jsonData.stream);
        jsonData.error && grunt.fail.warn(jsonData.error);
      });

      stream.on('error', callback);
      stream.on('end', function() {
        grunt.log.oklns('Build successfuly done.');
        callback();
      });
    });
  };

  var processDirectory = function(dirpath, buildOpts, callback) {
    grunt.log.debug('Packing directory [' + dirpath + ']');
    var pathentry = path.resolve(dirpath),
        dockerignore = pathentry + '/' +'.dockerignore',
        ignores = [];

    if (fs.statSync(dockerignore)) {
      grunt.log.debug('Detected a .dockerignore file, will perform ignoring tests');
      ignores = fs.readFileSync(dockerignore).toString().split("\n");
      ignores.push('.dockerignore');<commit_msg>- Adding the check for the .dockerignore exists<commit_after>/*
 * MIT License (MIT) - Copyright (c) 2014 <NAME>
 *
 * This file is part of <grunt-dock>.
 */
var fs = require('fs'),
    path = require('path'),
    tar = require('tar-stream'),
    tarfs = require('tar-fs'),
    concat = require('concat-stream'),
    zlib = require('zlib'),
    async = require('async'),
    utils = require('./utils');

/**
 * Build images.
 * Each image is a content associated with its tag name.
 * The content can be a regular file or whatever for Docker.
 * In case of a plain file, it will be tar + gz before sent
 * to Docker.
 *
 * @param  {Object}   grunt   The Grunt Object
 * @param  {Object}   docker  The Dockerode connection
 * @param  {Object}   options The Grunt options
 * @param  {Function} done    The done function to call when finished
 * @param  {String}   tag     The image tag to work with or null
 */
var buildCommands = function(grunt, docker, options, done, tag) {

  // Build image with tag and its data/options.
  // Call callback when done or error.
  var build = function(data, options, callback) {
    grunt.log.subhead('Building image [' + options.t + ']');

    docker.buildImage(data, options, function(err, stream) {

      if (err) {
        return callback(err);
      }

      stream.setEncoding('utf8');

      stream.on('data', function(data) {
        var jsonData = JSON.parse(data);
        jsonData.stream && grunt.log.write(jsonData.stream);
        jsonData.error && grunt.fail.warn(jsonData.error);
      });

      stream.on('error', callback);
      stream.on('end', function() {
        grunt.log.oklns('Build successfuly done.');
        callback();
      });
    });
  };

  var processDirectory = function(dirpath, buildOpts, callback) {
    grunt.log.debug('Packing directory [' + dirpath + ']');
    var pathentry = path.resolve(dirpath),
        dockerignore = pathentry + '/' +'.dockerignore',
        ignores = [];

    if (fs.existsSync(dockerignore) && fs.statSync(dockerignore)) {
      grunt.log.debug('Detected a .dockerignore file, will perform ignoring tests');
      ignores = fs.readFileSync(dockerignore).toString().split("\n");
      ignores.push('.dockerignore');
{'fraction_non_alphanumeric': 0.14305333028152895, 'fraction_numerical': 0.0022888532845044634, 'mean_word_length': 2.926325247079964, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1008706', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1293, 'n_words': 387}