<commit_before>'use strict';

let gulp = require('gulp');
let rimraf = require('gulp-rimraf');
let tsc = require('gulp-typescript');
let sourcemaps = require('gulp-sourcemaps');
let tslint = require('gulp-tslint');
let nodemon = require('gulp-nodemon');
let jasmine = require('gulp-jasmine');
let istanbul = require('gulp-istanbul');
let runSequence = require('run-sequence');

var path = require('path');

// /*  Variables */
let tsProject = tsc.createProject('./tsconfig.api.json');
let sourceFiles = [
  './api/**/*.ts',
  './common/**/*.ts',
  './typings/**/*.d.ts',
  '!./typings/index.d.ts',
  '!./typings/**/es6-shim/*.d.ts',
];
let testFiles = ['./api/**/*.spec.ts'];
let outDir = require('./tsconfig.api.json').compilerOptions.outDir;
let entryPoint = './localhost.js';

/**
 * Remove build directory.
 */
gulp.task('clean', function () {
  return gulp.src(['build', 'coverage'], {read: false})
    .pipe(rimraf())
});


/**
 * Lint all custom TypeScript files.
 */
gulp.task('tslint', () => {
  return gulp.src(sourceFiles.concat(['!./typings/**']))
    .pipe(tslint())
    .pipe(tslint.report('verbose'))
});

/**
 * Format all custom TypeScript files.
 */
gulp.task('format', (cb) => {
  var tsfmt = require('typescript-formatter/lib/index');
  var files = [];
  gulp.src(sourceFiles.concat(['!./typings/**']))
    .on('data', (file) => {
      files.push(file.path);
    })
    .on('end', () => {
      tsfmt.processFiles(files, {
        replace: true,
        verbose: false,
        baseDir: process.cwd(),
        editorconfig: true,
        tslint: true,
        tsfmt: true
      })
        .then((resultList) => {
          Object.keys(resultList).forEach((key) => {
            var result = resultList[key];
            if (result.message) {
              console.log(result.message);
            }
          });
          cb();
        }, cb);
    })
});

/**
 * Compile TypeScript sources and create sourcemaps in build directory.
 */
gulp.task('compile', ['clean'], () => {
  let tsResult = gulp.src(sourceFiles.concat(testFiles))
    .pipe(sourcemaps.init())
    .pipe(tsc(tsProject));
  return tsResult.js
    .pipe(sourcemaps.write('.', {sourceRoot: __dirname}))
    .pipe(gulp.dest(outDir))
});

/**
 * Watch for changes in TypeScript, HTML and CSS files.
 */
gulp.task('watch', function () {
  gulp.watch([sourceFiles], ['compile']).on('change', (e) => {
    console.log('TypeScript file ' + e.path + ' has been changed. Compiling.')
  })
});

/**
 * Build the project.
 */
gulp.task('build', ['compile'], () => {
  console.log('Building the project ...')
});

gulp.task('pre-test', function () {
  return gulp.src(['build/api/**/*.js'])
    // Covering files
    .pipe(istanbul())
    // Force `require` to return covered files
    .pipe(istanbul.hookRequire());
});

gulp.task('test', [], (callback) => {
  runSequence('build', 'pre-test', 'jasmine', callback);
});

gulp.task('jasmine', [], () => {
  Error.stackTraceLimit = Infinity;

  require('es6-shim');
  require('reflect-metadata');
  require('zone.js/dist/zone-node');

  const SpecReporter = require('jasmine-spec-reporter');

  return gulp.src(['build/api/**/*.js', '!build/api/api/bootstrap.js'])
    .pipe(jasmine({
        reporter: new SpecReporter({<commit_msg>fix(coverage): fixed coverage publishing failure due to build phase deleting the reports<commit_after>'use strict';

let gulp = require('gulp');
let rimraf = require('gulp-rimraf');
let tsc = require('gulp-typescript');
let sourcemaps = require('gulp-sourcemaps');
let tslint = require('gulp-tslint');
let nodemon = require('gulp-nodemon');
let jasmine = require('gulp-jasmine');
let istanbul = require('gulp-istanbul');
let runSequence = require('run-sequence');

var path = require('path');

// /*  Variables */
let tsProject = tsc.createProject('./tsconfig.api.json');
let sourceFiles = [
  './api/**/*.ts',
  './common/**/*.ts',
  './typings/**/*.d.ts',
  '!./typings/index.d.ts',
  '!./typings/**/es6-shim/*.d.ts',
];
let testFiles = ['./api/**/*.spec.ts'];
let outDir = require('./tsconfig.api.json').compilerOptions.outDir;
let entryPoint = './localhost.js';

/**
 * Remove build directory.
 */
gulp.task('clean-build', function () {
  return gulp.src(['build'], {read: false})
    .pipe(rimraf())
});

gulp.task('clean-coverage', function () {
  return gulp.src(['coverage'], {read: false})
    .pipe(rimraf())
});


/**
 * Lint all custom TypeScript files.
 */
gulp.task('tslint', () => {
  return gulp.src(sourceFiles.concat(['!./typings/**']))
    .pipe(tslint())
    .pipe(tslint.report('verbose'))
});

/**
 * Format all custom TypeScript files.
 */
gulp.task('format', (cb) => {
  var tsfmt = require('typescript-formatter/lib/index');
  var files = [];
  gulp.src(sourceFiles.concat(['!./typings/**']))
    .on('data', (file) => {
      files.push(file.path);
    })
    .on('end', () => {
      tsfmt.processFiles(files, {
        replace: true,
        verbose: false,
        baseDir: process.cwd(),
        editorconfig: true,
        tslint: true,
        tsfmt: true
      })
        .then((resultList) => {
          Object.keys(resultList).forEach((key) => {
            var result = resultList[key];
            if (result.message) {
              console.log(result.message);
            }
          });
          cb();
        }, cb);
    })
});

/**
 * Compile TypeScript sources and create sourcemaps in build directory.
 */
gulp.task('compile', ['clean-build'], () => {
  let tsResult = gulp.src(sourceFiles.concat(testFiles))
    .pipe(sourcemaps.init())
    .pipe(tsc(tsProject));
  return tsResult.js
    .pipe(sourcemaps.write('.', {sourceRoot: __dirname}))
    .pipe(gulp.dest(outDir))
});

/**
 * Watch for changes in TypeScript, HTML and CSS files.
 */
gulp.task('watch', function () {
  gulp.watch([sourceFiles], ['compile']).on('change', (e) => {
    console.log('TypeScript file ' + e.path + ' has been changed. Compiling.')
  })
});

/**
 * Build the project.
 */
gulp.task('build', ['compile'], () => {
  console.log('Building the project ...')
});

gulp.task('pre-test', ['clean-coverage'], () => {
  return gulp.src(['build/api/**/*.js'])
    // Covering files
    .pipe(istanbul())
    // Force `require` to return covered files
    .pipe(istanbul.hookRequire());
});

gulp.task('test', [], (callback) => {
  runSequence('build', 'pre-test', 'jasmine', callback);
});

gulp.task('jasmine', [], () => {
  Error.stackTraceLimit = Infinity;

  require('es6-shim');
  require('reflect-metadata');
  require('zone.js/dist/zone-node');

  const SpecReporter = require('jasmine-spec-reporter');

  return gulp.src(['build/api/**/*.js', '!build/api/api/bootstrap.js'])
    .pipe(jasmine({
        reporter: new SpecReporter({
{'fraction_non_alphanumeric': 0.21669891352879894, 'fraction_numerical': 0.0005953266855186784, 'mean_word_length': 3.1687344913151363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '4838135', 'n_tokens_mistral': 2270, 'n_tokens_neox': 2244, 'n_words': 416}