<commit_before>var gulp = require('gulp');
var ts = require('gulp-typescript');
var rimraf = require('gulp-rimraf');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var copy = require('gulp-copy');
var concat = require('gulp-concat-util');
var exec = require('child_process').exec;
var fs = require('fs');

gulp.task('clean-build-folder', function () {
  return gulp.src('built/**/*', { read: false })
    .pipe(rimraf());
});

gulp.task('build', function (done) {
  var tsconfig = require("./tsconfig.json");
  var filesGlob = tsconfig.filesGlob;
   
  tsconfig.compilerOptions.typescript = require('typescript');
 
  return gulp.src(filesGlob)
      .pipe(ts(tsconfig.compilerOptions))
      .pipe(gulp.dest(tsconfig.compilerOptions.outDir));
});

gulp.task('copy-api-definitions', function () {
  return gulp.src('./definitions/api.d.ts')
    .pipe(rename('syringe.d.ts'))
    .pipe(gulp.dest('./dist'));
});

gulp.task('copy-definitions', ['copy-api-definitions'], function() {
    return gulp.src('./definitions/es6-promise/**/*')
      .pipe(gulp.dest('./dist/es6-promise'));
});

gulp.task('package', ['build', 'copy-definitions'], function (done) {
  var outFolder = './dist';
  var browserify = require('browserify');
  var b = browserify({
    entries: 'built/src/index.js',
    debug: false,
    standalone: 'syringe'
  });
  
  return b
    .bundle()
    .pipe(source('syringe.js'))
    .pipe(buffer())
    .pipe(concat.header(fs.readFileSync('./license-comment.txt')))
    .pipe(gulp.dest(outFolder))
    .pipe(uglify())
    .pipe(concat.header(fs.readFileSync('./license-comment.txt')))
    .pipe(rename({ extname: '.min.js' }))
    .pipe(gulp.dest(outFolder));
});

gulp.task('unit', ['build'], function () {
  var karma = require('gulp-karma');
  var testFiles = [
    'built/test/**/*.js'
  ];
  
  return gulp.src(testFiles)
      .pipe(karma({
        configFile: 'karma.conf.js',
        action: 'run'
      }))
      .on('error', function(err) {
        // Make sure failed tests cause gulp to exit non-zero 
        throw err;
      });  
});<commit_msg>adds unit.ci gulp task<commit_after>var gulp = require('gulp');
var ts = require('gulp-typescript');
var rimraf = require('gulp-rimraf');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var copy = require('gulp-copy');
var concat = require('gulp-concat-util');
var exec = require('child_process').exec;
var fs = require('fs');

function runKarmaTests(confFile) {
  var karma = require('gulp-karma');
  var testFiles = [
    'built/test/**/*.js'
  ];

  return gulp.src(testFiles)
    .pipe(karma({
      configFile: confFile,
      action: 'run'
    }))
    .on('error', function (err) {
      // Make sure failed tests cause gulp to exit non-zero 
      throw err;
    });
}

gulp.task('clean-build-folder', function () {
  return gulp.src('built/**/*', { read: false })
    .pipe(rimraf());
});

gulp.task('build', function (done) {
  var tsconfig = require("./tsconfig.json");
  var filesGlob = tsconfig.filesGlob;

  tsconfig.compilerOptions.typescript = require('typescript');

  return gulp.src(filesGlob)
    .pipe(ts(tsconfig.compilerOptions))
    .pipe(gulp.dest(tsconfig.compilerOptions.outDir));
});

gulp.task('copy-api-definitions', function () {
  return gulp.src('./definitions/api.d.ts')
    .pipe(rename('syringe.d.ts'))
    .pipe(gulp.dest('./dist'));
});

gulp.task('copy-definitions', ['copy-api-definitions'], function () {
  return gulp.src('./definitions/es6-promise/**/*')
    .pipe(gulp.dest('./dist/es6-promise'));
});

gulp.task('package', ['build', 'copy-definitions'], function (done) {
  var outFolder = './dist';
  var browserify = require('browserify');
  var b = browserify({
    entries: 'built/src/index.js',
    debug: false,
    standalone: 'syringe'
  });

  return b
    .bundle()
    .pipe(source('syringe.js'))
    .pipe(buffer())
    .pipe(concat.header(fs.readFileSync('./license-comment.txt')))
    .pipe(gulp.dest(outFolder))
    .pipe(uglify())
    .pipe(concat.header(fs.readFileSync('./license-comment.txt')))
    .pipe(rename({ extname: '.min.js' }))
    .pipe(gulp.dest(outFolder));
});

gulp.task('unit', ['build'], function () {
  runKarmaTests('karma.conf.js');
});

gulp.task('unit.ci', ['build'], function () {
  runKarmaTests('karma-sauce.conf.js');
});
{'fraction_non_alphanumeric': 0.20586275816122585, 'fraction_numerical': 0.0008882966910948257, 'mean_word_length': 3.741052631578947, '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': '2911693', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1566, 'n_words': 269}