<commit_before>gulp = require 'gulp'
# browserify = require 'browserify'
# buffer = require 'vinyl-buffer'
coffee = require 'gulp-coffee'
clean = require 'gulp-clean'
mocha = require 'gulp-mocha'
rm = require 'del'
source = require 'vinyl-source-stream'

logger = require('printit')
	date: false
	prefix: 'gulp'

BUILDDIR = 'build/'


gulp.task 'default', ['b']
gulp.task 'b' , ['build-client', 'build-server']	# build
gulp.task 't' , ['test-client', 'test-server']		# test

	 
gulp.task 'build-client', () ->
	logger.options.prefix = 'gulp:build-client'
	logger.info "Start compilation..."

	# rm BUILDDIR + 'client/' 

	# gulp.src 'static/**/*'
	 # .pipe gulp.dest BUILDDIR + 'client/'
	
	# bundler = browserify {
		# entries: ['./client/main.js'],
		# debug: true
	
	# bundler
	 # .transform babelify
	 # .bundle 
		# .on 'error', (err) ->
			# logger.error 'Bundle error: ' + err 
			# this.end 
		
	 # .pipe source 'main.js'
	 # .pipe buffer 
	 # .pipe gulp.dest BUILDDIR + 'client/js'
	 
	logger.error "No gulp-task defined yet."

	logger.info "Compilation succeeded."


gulp.task 'build-server', () ->
	logger.options.prefix = 'gulp:build-server'
	logger.info "Start compilation..."
	
	rm [BUILDDIR + 'server/', 'server.js']

	gulp.src 'server/**/*.coffee'
	 .pipe coffee .on 'error', logger.error
	 .pipe gulp.dest BUILDDIR + 'server/'
	
	gulp.src 'server.coffee'
	 .pipe coffee .on 'error', logger.error
	 .pipe gulp.dest BUILDDIR

	gulp.src 'package.json'
	 .pipe gulp.dest BUILDDIR

	logger.info "Compilation succeeded."



gulp.task 'test-client', () ->
	logger.options.prefix = 'gulp:test-client'
	logger.info "Start testing client..."
	
	# gulp.src ['tests/controllers/*.coffee'], read: false
	 # .pipe mocha reporter: 'spec'
	  # .on 'error', logger.error
	logger.error "No test implemented yet."

	logger.info "Testing client done."

gulp.task 'test-server', () ->
	logger.options.prefix = 'gulp:test-server'
	logger.info "Start testing server..."
	
	gulp.src ['tests/controllers/*.coffee'], read: false
	 .pipe mocha reporter: 'spec'
	  .on 'error', console.log.bind(console)

	logger.info "Testing server done."


gulp.task 'w', ['test-client', 'test-server'], () ->	# watch
	gulp.watch ['client/**/*.js', 'static/**/*'], ['test-client']
	gulp.watch ['server/**/*.coffee', 'server.coffee', 'tests/**/*'], ['test-server']
	
# gulp.task 'w' /* watch */, ['build-client', 'build-server'], () ->
	# gulp.watch ['client/**/*.js', 'static/**/*'], ['build-client']
	# gulp.watch ['server/**/*.coffee', 'server.coffee'], ['build-server']


gulp.task 'clean', () ->
	gulp.src BUILDDIR, force: true 
	 .pipe clean<commit_msg><admin> Gulpfile - quickfix to display errors.<commit_after>gulp = require 'gulp'
# browserify = require 'browserify'
# buffer = require 'vinyl-buffer'
gutil = require 'gulp-util'
coffee = require 'gulp-coffee'
clean = require 'gulp-clean'
mocha = require 'gulp-mocha'
rm = require 'del'
source = require 'vinyl-source-stream'

logger = require('printit')
	date: false
	prefix: 'gulp'

BUILDDIR = 'build/'

watching = false
handleError = (err) ->
	logger.error err.toString
	if watching
		this.emit 'end'
	else
		process.exit 1


gulp.task 'default', ['b']
gulp.task 'b' , ['build-client', 'build-server']	# build
gulp.task 't' , ['test-client', 'test-server']		# test

	 
gulp.task 'build-client', () ->
	logger.options.prefix = 'gulp:build-client'
	logger.info "Start compilation..."

	# rm BUILDDIR + 'client/' 

	# gulp.src 'static/**/*'
	 # .pipe gulp.dest BUILDDIR + 'client/'
	
	# bundler = browserify {
		# entries: ['./client/main.js'],
		# debug: true
	
	# bundler
	 # .transform babelify
	 # .bundle 
		# .on 'error', (err) ->
			# logger.error 'Bundle error: ' + err 
			# this.end 
		
	 # .pipe source 'main.js'
	 # .pipe buffer 
	 # .pipe gulp.dest BUILDDIR + 'client/js'
	 
	logger.error "No gulp-task defined yet."

	logger.info "Compilation succeeded."


gulp.task 'build-server', () ->
	logger.options.prefix = 'gulp:build-server'
	logger.info "Start compilation..."
	
	rm [BUILDDIR + 'server/', 'server.js']

	gulp.src('server/**/*.coffee')
	 .pipe(coffee({bare: true}).on('error', gutil.log))
	 .pipe(gulp.dest BUILDDIR + 'server/')
	
	gulp.src('server.coffee')
	 .pipe(coffee({bare: true}).on('error', gutil.log))
	 .pipe(gulp.dest BUILDDIR)

	gulp.src('package.json')
	 .pipe(gulp.dest BUILDDIR)

	logger.info "Compilation succeeded."



gulp.task 'test-client', () ->
	logger.options.prefix = 'gulp:test-client'
	logger.info "Start testing client..."
	
	# gulp.src ['tests/controllers/*.coffee'], read: false
	 # .pipe mocha reporter: 'spec'
	  # .on 'error', logger.error
	logger.error "No test implemented yet."

	logger.info "Testing client done."

gulp.task 'test-server', () ->
	logger.options.prefix = 'gulp:test-server'
	logger.info "Start testing server..."
	
	gulp.src ['tests/controllers/*.coffee'], read: false
	 .pipe(mocha({reporter: 'spec'}).on('error', gutil.log))

	logger.info "Testing server done."


gulp.task 'w', ['test-client', 'test-server'], () ->	# watch
	watching = true
	gulp.watch ['client/**/*.js', 'static/**/*'], ['test-client']
	gulp.watch ['server/**/*.coffee', 'server.coffee', 'tests/**/*'], ['test-server']
	
# gulp.task 'w' /* watch */, ['build-client', 'build-server'], () ->
	# gulp.watch ['client/**/*.js', 'static/**/*'], ['build-client']
	# gulp.watch ['server/**/*.coffee', 'server.coffee'], ['build-server']


gulp.task 'clean', () ->
	gulp.src BUILDDIR, force: true 
	 .pipe clean
{'fraction_non_alphanumeric': 0.20032840722495895, 'fraction_numerical': 0.00018244845831052726, 'mean_word_length': 3.5418392709196356, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 21, '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': '4069021', 'n_tokens_mistral': 2088, 'n_tokens_neox': 1954, 'n_words': 452}