<commit_before>var gulp          = require('gulp');
var postcss       = require('gulp-postcss');
var less          = require('gulp-less');
var autoprefixer  = require('autoprefixer');
var browserSync   = require('browser-sync').create();
var webpack       = require('webpack-stream');
var clean         = require('gulp-clean');
var runSequence   = require('run-sequence');
var sourcemaps    = require('gulp-sourcemaps');
var KarmaServer   = require('karma').Server;


var config = {
  path: {
    less:                 './app/less/',
    output_folder:        './dist/',
    output_folder_css:    './dist/css/',
    output_folder_images: './dist/images/',
    output_folder_fonts:  './dist/fonts/',
    node_modules:         './node_modules/'
  }
};

function showError(err) {
  console.log('Error: ', err);
}

function createServer(openBrowser){
  browserSync.init({
    server : {
      baseDir: config.path.output_folder,
    },
    open: openBrowser,
    ghostMode: false,
    middleware: require('./api/router')
  });
}


gulp.task('browser-sync', function() {
  createServer(false);
});

gulp.task('restart-server', function() {
	Promise
    .all([browserSync.exit()])
    .then(function(){
      createServer(false);
    })
});

gulp.task('bootstrap-less', function () {
	var processors = [
		autoprefixer
	];

	return gulp.src(config.path.less + 'bootstrap.less')
    .pipe(sourcemaps.init())
    .pipe(less())
		.pipe(postcss(processors))
    .pipe(sourcemaps.write('./maps'))
		.pipe(gulp.dest(config.path.output_folder_css));
});

gulp.task('less', function () {
	var processors = [
		autoprefixer
	];
	return gulp.src(['./app/routes/**/*.less'])
    .pipe(sourcemaps.init())
    .pipe(less())
    .pipe(postcss(processors))
    .pipe(sourcemaps.write('./maps'))
    .pipe(gulp.dest(config.path.output_folder_css));
});

// Moves html and mustache partials files to dist folder
gulp.task('html', function () {
  return gulp.src(['./app/**/*.html', './app/**/*.mustache'])    
    .pipe(gulp.dest(config.path.output_folder));
});

// Moves images files to dist folder
gulp.task('images', function () {
  return gulp.src('./app/images/**/')    
    .pipe(gulp.dest(config.path.output_folder_images));
});

// Moves fonts files to dist folder
gulp.task('fonts', function () {
  return gulp.src('./app/fonts/**/')    
    .pipe(gulp.dest(config.path.output_folder_fonts));
});

// Delete everything in /dist
gulp.task('clean-dist', function () {<commit_msg>Avoid less watch task died after error.<commit_after>var gulp          = require('gulp');
var postcss       = require('gulp-postcss');
var less          = require('gulp-less');
var autoprefixer  = require('autoprefixer');
var browserSync   = require('browser-sync').create();
var webpack       = require('webpack-stream');
var clean         = require('gulp-clean');
var runSequence   = require('run-sequence');
var sourcemaps    = require('gulp-sourcemaps');
var KarmaServer   = require('karma').Server;


var config = {
  path: {
    less:                 './app/less/',
    output_folder:        './dist/',
    output_folder_css:    './dist/css/',
    output_folder_images: './dist/images/',
    output_folder_fonts:  './dist/fonts/',
    node_modules:         './node_modules/'
  }
};

function showError(err) {
  console.log('Error: ', err);
  this.emit('end');
}

function createServer(openBrowser){
  browserSync.init({
    server : {
      baseDir: config.path.output_folder,
    },
    open: openBrowser,
    ghostMode: false,
    middleware: require('./api/router')
  });
}


gulp.task('browser-sync', function() {
  createServer(false);
});

gulp.task('restart-server', function() {
	Promise
    .all([browserSync.exit()])
    .then(function(){
      createServer(false);
    })
});

gulp.task('bootstrap-less', function () {
	var processors = [
		autoprefixer
	];

	return gulp.src(config.path.less + 'bootstrap.less')
    .pipe(sourcemaps.init())
    .pipe(less().on('error', function(e){
      showError.call(this, e);
    }))
		.pipe(postcss(processors))
    .pipe(sourcemaps.write('./maps'))
    
		.pipe(gulp.dest(config.path.output_folder_css));
});

gulp.task('less', function () {
	var processors = [
		autoprefixer
	];
	return gulp.src(['./app/routes/**/*.less'])
    .pipe(sourcemaps.init())
    .pipe(less().on('error', function(e){
      showError.call(this, e);
    }))
    .pipe(postcss(processors))
    .pipe(sourcemaps.write('./maps'))
    .pipe(gulp.dest(config.path.output_folder_css));
});

// Moves html and mustache partials files to dist folder
gulp.task('html', function () {
  return gulp.src(['./app/**/*.html', './app/**/*.mustache'])    
    .pipe(gulp.dest(config.path.output_folder));
});

// Moves images files to dist folder
gulp.task('images', function () {
  return gulp.src('./app/images/**/')    
    .pipe(gulp.dest(config.path.output_folder_images));
});

// Moves fonts files to dist folder
gulp.task('fonts', function () {
  return gulp.src('./app/fonts/**/')    
    .pipe(gulp.dest(config.path.output_folder_fonts));
});

// Delete everything in /dist
gulp.task('clean-dist', function () {
{'fraction_non_alphanumeric': 0.19020568070519098, 'fraction_numerical': 0.0, 'mean_word_length': 3.2303231151615575, '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': '7264764', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1711, 'n_words': 289}