<commit_before>/*global afterEach, beforeEach, describe, it */
'use strict';

var assert = require('assert');
var binCheck = require('bin-check');
var execFile = require('child_process').execFile;
var fs = require('fs');
var path = require('path');
var rm = require('rimraf');

describe('jpegRecompress()', function () {
  afterEach(function (callback) {
    rm(path.join(__dirname, 'tmp'), callback);
  });

  beforeEach(function () {
    fs.mkdirSync(path.join(__dirname, 'tmp'));
  });

  it('should return path to binary and verify that it is working', function (callback) {
    var binPath = require('../').path;

    binCheck(binPath, ['--version'], function (error, works) {
      assert(!error);
      assert.equal(works, true);
      callback();
    });
  });

  it('should minify a JPEG', function (callback) {
    var binPath = require('../').path;
    var args = [
      '--quality',
      'high',
      '--min',
      '60',
      path.join(__dirname, 'fixtures/test.jpg'),
      path.join(__dirname, 'tmp/test.jpg')
    ];

    execFile(binPath, args, function (error) {
      var src = fs.statSync(path.join(__dirname, 'fixtures/test.jpg')).size;
      var dest = fs.statSync(path.join(__dirname, 'tmp/test.jpg')).size;

      assert(!error);
      assert(dest < src);
      callback();
    });
  });
});
<commit_msg>invoke callback with an error as its argument<commit_after>/*global afterEach, beforeEach, describe, it */
'use strict';

var assert = require('assert');
var binCheck = require('bin-check');
var execFile = require('child_process').execFile;
var fs = require('fs');
var path = require('path');
var rm = require('rimraf');

describe('jpegRecompress()', function () {
  afterEach(function (callback) {
    rm(path.join(__dirname, 'tmp'), callback);
  });

  beforeEach(function () {
    fs.mkdirSync(path.join(__dirname, 'tmp'));
  });

  it('should return path to binary and verify that it is working', function (callback) {
    var binPath = require('../').path;

    binCheck(binPath, ['--version'], function (error, works) {
      if (error) {
        callback(error);
        return;
      }
      
      assert.equal(works, true);
      callback();
    });
  });

  it('should minify a JPEG', function (callback) {
    var binPath = require('../').path;
    var args = [
      '--quality',
      'high',
      '--min',
      '60',
      path.join(__dirname, 'fixtures/test.jpg'),
      path.join(__dirname, 'tmp/test.jpg')
    ];

    execFile(binPath, args, function (error) {
      var src = fs.statSync(path.join(__dirname, 'fixtures/test.jpg')).size;
      var dest = fs.statSync(path.join(__dirname, 'tmp/test.jpg')).size;
      
      if (error) {
        callback(error);
        return;
      }
      assert(dest < src);
      callback();
    });
  });
});

{'fraction_non_alphanumeric': 0.18149339049660593, 'fraction_numerical': 0.0014290818149339049, 'mean_word_length': 3.005722460658083, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4281028', 'n_tokens_mistral': 883, 'n_tokens_neox': 867, 'n_words': 203}