 gulp = require 'gulp'
-# browserify = require 'browserify'
-# buffer = require 'vinyl-buffer'
+browserify = require 'browserify'
+buffer = require 'vinyl-buffer'
+concat = require 'gulp-concat'
+babelify = require 'babelify'
 gutil = require 'gulp-util'
 coffee = require 'gulp-coffee'
 clean = require 'gulp-clean'

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."


	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')
