<commit_before>/* jshint camelcase: false, strict: false */
/* global describe, beforeEach, it */
var chai = require('chai'),
    should = chai.should(),
    util = require('util'),
    gutil = require('gulp-util'),
    path = require('path'),
    commandRunner = require('../lib/test_commandRunner'),
    install = require('../.'),
    args = process.argv.slice();

function fixture (file) {
  var filepath = path.join(__dirname, file);
  return new gutil.File({
    path: filepath,
    cwd: __dirname,
    base: path.join(__dirname, path.dirname(file)),
    contents: null
  });
}

describe('gulp-install', function () {
  beforeEach(function () {
    commandRunner.reset();
    process.argv = args;
  });

  it('should run `npm install` if stream contains `package.json`', function (done) {
    var file = fixture('package.json');

    var stream = install();

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function () {
    });

    stream.on('end', function () {
      commandRunner.commandsThatHasRun.length.should.equal(1);
      commandRunner.commandsThatHasRun[0].cmd.should.equal('npm');
      commandRunner.commandsThatHasRun[0].args.should.eql(['install']);
      done();
    });

    stream.write(file);

    stream.end();
  });

  it('should run `bower install` if stream contains `bower.json`', function (done) {
    var file = fixture('bower.json');

    var stream = install();

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function () {
    });

    stream.on('end', function () {
      commandRunner.commandsThatHasRun.length.should.equal(1);
      commandRunner.commandsThatHasRun[0].cmd.should.equal('bower');
      commandRunner.commandsThatHasRun[0].args.should.eql(['install']);
      done();
    });

    stream.write(file);

    stream.end();
  });

  it('should run both `npm install` and `bower install` if stream contains both `package.json` and `bower.json`', function (done) {
    var files = [
      fixture('package.json'),
      fixture('bower.json')
    ];

    var stream = install();

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function () {
    });

    stream.on('end', function () {
      commandRunner.commandsThatHasRun.length.should.equal(2);
      commandRunner.commandsThatHasRun[0].cmd.should.equal('npm');
      commandRunner.commandsThatHasRun[0].args.should.eql(['install']);
      commandRunner.commandsThatHasRun[1].cmd.should.equal('bower');
      commandRunner.commandsThatHasRun[1].args.should.eql(['install']);
      done();
    });

    files.forEach(function (file) {
      stream.write(file);
    });

    stream.end();
  });

  it('should not run any installs when `--skip-install` CLI option is provided', function (done) {
    var newArgs = args.slice();
    newArgs.push('--skip-install');
    process.argv = newArgs;

    var files = [
      fixture('package.json'),
      fixture('bower.json')
    ];

    var stream = install();

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function () {
    });

    stream.on('end', function () {
      commandRunner.commandsThatHasRun.length.should.equal(0);
      done();
    });

    files.forEach(function (file) {
      stream.write(file);
    });

    stream.end();
  });
});<commit_msg>Adding test to verify #7<commit_after>/* jshint camelcase: false, strict: false */
/* global describe, beforeEach, it */
var chai = require('chai'),
    should = chai.should(),
    util = require('util'),
    gutil = require('gulp-util'),
    path = require('path'),
    commandRunner = require('../lib/test_commandRunner'),
    install = require('../.'),
    args = process.argv.slice();

function fixture (file) {
  var filepath = path.join(__dirname, file);
  return new gutil.File({
    path: filepath,
    cwd: __dirname,
    base: path.join(__dirname, path.dirname(file)),
    contents: null
  });
}

describe('gulp-install', function () {
  beforeEach(function () {
    commandRunner.reset();
    process.argv = args;
  });

  it('should run `npm install` if stream contains `package.json`', function (done) {
    var file = fixture('package.json');

    var stream = install();

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function () {
    });

    stream.on('end', function () {
      commandRunner.commandsThatHasRun.length.should.equal(1);
      commandRunner.commandsThatHasRun[0].cmd.should.equal('npm');
      commandRunner.commandsThatHasRun[0].args.should.eql(['install']);
      done();
    });

    stream.write(file);

    stream.end();
  });

  it('should run `bower install` if stream contains `bower.json`', function (done) {
    var file = fixture('bower.json');

    var stream = install();

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function () {
    });

    stream.on('end', function () {
      commandRunner.commandsThatHasRun.length.should.equal(1);
      commandRunner.commandsThatHasRun[0].cmd.should.equal('bower');
      commandRunner.commandsThatHasRun[0].args.should.eql(['install']);
      done();
    });

    stream.write(file);

    stream.end();
  });

  it('should run both `npm install` and `bower install` if stream contains both `package.json` and `bower.json`', function (done) {
    var files = [
      fixture('package.json'),
      fixture('bower.json')
    ];

    var stream = install();

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function () {
    });

    stream.on('end', function () {
      commandRunner.commandsThatHasRun.length.should.equal(2);
      commandRunner.commandsThatHasRun[0].cmd.should.equal('npm');
      commandRunner.commandsThatHasRun[0].args.should.eql(['install']);
      commandRunner.commandsThatHasRun[1].cmd.should.equal('bower');
      commandRunner.commandsThatHasRun[1].args.should.eql(['install']);
      done();
    });

    files.forEach(function (file) {
      stream.write(file);
    });

    stream.end();
  });

  it('should not run any installs when `--skip-install` CLI option is provided', function (done) {
    var newArgs = args.slice();
    newArgs.push('--skip-install');
    process.argv = newArgs;

    var files = [
      fixture('package.json'),
      fixture('bower.json')
    ];

    var stream = install();

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function () {
    });

    stream.on('end', function () {
      commandRunner.commandsThatHasRun.length.should.equal(0);
      done();
    });

    files.forEach(function (file) {
      stream.write(file);
    });

    stream.end();
  });

  it('should set `cwd` correctly to be able to run the same command in multiple folders', function (done) {
    var files = [
      fixture('dir1/package.json'),
      fixture('dir2/package.json')
    ];

    var stream = install();

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function () {
    });

    stream.on('end', function () {
      commandRunner.commandsThatHasRun.length.should.equal(2);
      commandRunner.commandsThatHasRun[0].cmd.should.equal('npm');
      commandRunner.commandsThatHasRun[0].args.should.eql(['install']);
      commandRunner.commandsThatHasRun[0].cwd.should.equal(path.join(__dirname, 'dir1'));
      commandRunner.commandsThatHasRun[1].cmd.should.equal('npm');
      commandRunner.commandsThatHasRun[1].args.should.eql(['install']);
      commandRunner.commandsThatHasRun[1].cwd.should.equal(path.join(__dirname, 'dir2'));
      done();
    });

    files.forEach(function (file) {
      stream.write(file);
    });

    stream.end();
  });
});
{'fraction_non_alphanumeric': 0.17591780478636762, 'fraction_numerical': 0.004510712943240195, 'mean_word_length': 3.0374304501770357, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '313053', 'n_tokens_mistral': 2518, 'n_tokens_neox': 2444, 'n_words': 438}