<commit_before>var gulp          = require('gulp');
var tsconfig      = require('gulp-tsconfig-files');
var tsd           = require('gulp-tsd');
var exec          = require('child_process').execSync;
var install       = require('gulp-install');

function run(command, cb) {
  console.log('Run command: ' + command);
  exec(command, function(err, stdout, stderr) {
    if (err) {
      console.log('### ERROR ON COMMAND ' + command + ':');
      console.log(stdout);
      cb(err);
      throw err;
    }

    return cb(err);
  });
}

// This task runs tsd command on csComp folder
gulp.task('comp_tsd', function(cb) {
  tsd({
    command: 'reinstall',
    config: 'csComp/tsd.json',
  }, cb);
});

// This task updates the typescript dependencies on tsconfig file for csComp
gulp.task('comp_tsconfig_files', function() {
  gulp.src(['./csComp/**/*.ts',
            './csComp/**/*.ts',
            '!./csComp/dist/csComp.d.ts',
            '!./csComp/js/**/*.d.ts',
            '!./csComp/js/**/*.js',
            '!./csComp/node_modules/**/*.ts',
        ],
      {base: 'csComp'})
    .pipe(tsconfig({
      path:         'csComp/tsconfig.json',
      relative_dir: 'csComp/',
    }));
});

// This task compiles typescript on csComp
gulp.task('comp_tsc', function(cb) {
  return run('tsc -p csComp', cb);
});

// This task runs tsd command on csServerComp folder
gulp.task('servercomp_tsd', function(cb) {
  tsd({
    command: 'reinstall',
    config: 'csServerComp/tsd.json',
  }, cb);
});

// This task updates the typescript dependencies on tsconfig file for csServerComp
gulp.task('servercomp_tsconfig_files', function() {
  gulp.src(['csServerComp/**/*.ts',
            '!csServerComp/OfflineSearch/**/*.ts',
            '!csServerComp/ServerComponents/**/*.d.ts',
            '!csServerComp/node_modules/**/*.ts',
            '!csServerComp/Classes/*.d.ts',
        ],
      {base: 'csServerComp'})
    .pipe(tsconfig({
      path:         'csServerComp/tsconfig.json',
      relative_dir: 'csServerComp/',
    }));
});

// This task compiles typescript on csServerComp
gulp.task('servercomp_tsc', function(cb) {
  return run('tsc -p csServerComp', cb);
});

// Run required npm and bower installs for example folder
gulp.task('example_deps', function() {
  gulp.src([
      'example/package.json',       // npm install
      'example/public/bower.json',  // bower install
    ])
    .pipe(install());
});

gulp.task('init', [
    'comp_tsconfig_files',
    'comp_tsd',
    // 'comp_tsc',
    'servercomp_tsd',
    'servercomp_tsconfig_files',
    'servercomp_tsc',
    'example_deps',
]);<commit_msg>Better error reporting on gulp tasks<commit_after>var gulp          = require('gulp');
var tsconfig      = require('gulp-tsconfig-files');
var tsd           = require('gulp-tsd');
var exec          = require('child_process').execSync;
var install       = require('gulp-install');

function run(command) {
  console.log('Run command: ' + command);
  try {
    exec(command);
  } catch(err) {
    console.log('### Exception encountered on command: ' + command);
    console.log(err.stdout.toString());
    console.log('####################################');
    throw err;
  }
}

// This task runs tsd command on csComp folder
gulp.task('comp_tsd', function(cb) {
  tsd({
    command: 'reinstall',
    config: 'csComp/tsd.json',
  }, cb);
});

// This task updates the typescript dependencies on tsconfig file for csComp
gulp.task('comp_tsconfig_files', function() {
  gulp.src(['./csComp/**/*.ts',
            './csComp/**/*.ts',
            '!./csComp/dist/csComp.d.ts',
            '!./csComp/js/**/*.d.ts',
            '!./csComp/js/**/*.js',
            '!./csComp/node_modules/**/*.ts',
        ],
      {base: 'csComp'})
    .pipe(tsconfig({
      path:         'csComp/tsconfig.json',
      relative_dir: 'csComp/',
    }));
});

// This task compiles typescript on csComp
gulp.task('comp_tsc', function(cb) {
  return run('tsc -p csComp', cb);
});

// This task runs tsd command on csServerComp folder
gulp.task('servercomp_tsd', function(cb) {
  tsd({
    command: 'reinstall',
    config: 'csServerComp/tsd.json',
  }, cb);
});

// This task updates the typescript dependencies on tsconfig file for csServerComp
gulp.task('servercomp_tsconfig_files', function() {
  gulp.src(['csServerComp/**/*.ts',
            '!csServerComp/OfflineSearch/**/*.ts',
            '!csServerComp/ServerComponents/**/*.d.ts',
            '!csServerComp/node_modules/**/*.ts',
            '!csServerComp/Classes/*.d.ts',
        ],
      {base: 'csServerComp'})
    .pipe(tsconfig({
      path:         'csServerComp/tsconfig.json',
      relative_dir: 'csServerComp/',
    }));
});

// This task compiles typescript on csServerComp
gulp.task('servercomp_tsc', function(cb) {
  return run('tsc -p csServerComp', cb);
});

// Run required npm and bower installs for example folder
gulp.task('example_deps', function() {
  gulp.src([
      'example/package.json',       // npm install
      'example/public/bower.json',  // bower install
    ])
    .pipe(install());
});

gulp.task('init', [
    'comp_tsconfig_files',
    'comp_tsd',
    'comp_tsc',
    'servercomp_tsd',
    'servercomp_tsconfig_files',
    'servercomp_tsc',
    'example_deps',
]);
{'fraction_non_alphanumeric': 0.18426067073170732, 'fraction_numerical': 0.0, 'mean_word_length': 2.7439372325249645, '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': '2297000', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1746, 'n_words': 348}