 			fs.symlinkSync src, dest
 
 
-
-
 	##############
 	### EVENTS ###
 	##############
 
 	grunt.event.on 'watch', (action, srcPath) ->
-		if srcPath.substr(0, 3) is 'src' # Make sure file comes from src/		
-			type = 'coffee' if srcPath.substr(-7) is '.coffee'
-			type = 'jade' if srcPath.substr(-5) is '.jade'
+		if srcPath.substr(0, 3) is 'src' # Make sure file comes from src/
+			type = (srcPath.split('.').splice -1)[0]
 
 			if type is 'coffee'
 				testDestPath = srcPath.replace 'src/coffee', 'test'
 				destPath = 'compiled'+srcPath.replace(new RegExp(type, 'g'), 'js').substr(3);
 
 			if type is 'jade'
-				destPath = 'compiled'+srcPath.replace(new RegExp(type, 'g'), 'html').substr(3);
+				destPath = 'compiled' + srcPath.replace(new RegExp(type, 'g'), 'html').substr(3);
 
 			if type? and action is 'changed' or action is 'added'
 				data = {}

					base: ''
					middleware: connect_middleware

		### HTML ###
		
		jade:

	### TASKS ###
	#############

	tasks = [
		'grunt-contrib-coffee'
		'grunt-contrib-concat'
		'grunt-contrib-connect'
		'grunt-contrib-copy'
		'grunt-contrib-cssmin'
		'grunt-contrib-jade'
		'grunt-contrib-requirejs'
		'grunt-contrib-stylus'
		'grunt-contrib-uglify'
		'grunt-contrib-watch'
		'grunt-shell'
		'grunt-text-replace'
		'grunt-groc'
		'grunt-rsync'
	]

	grunt.loadNpmTasks task for task in tasks

	jobs = [
			# default
			aliases: ['default']
			tasks: ['sw']
		,
			# generate docs
			aliases: ['d']
			tasks: ['shell:groc']
		,
			# server
			aliases: ['s']
			tasks:['connect:keepalive']
		,
			# watch
			aliases: ['w']
			tasks: ['watch']
		,
			# server and watch
			aliases: ['sw']
			tasks: [
				'connect:compiled'
				'connect:dist'
				'connect:test'
				'watch'
			]
		,
			# compile
			aliases: ['c', 'compile']
			tasks: [
				'shell:emptycompiled'	# rm -rf compiled/
				'shell:bowerinstall'	# Get dependencies first, cuz css needs to be included (and maybe images?)
				'createSymlinks:compiled'
				'coffee:init'
				'jade:init'
				'stylus:compile'
				'rsync:compiled'
				'concat:css'
			]
		,
			# build
			aliases: ['b', 'build']
			tasks: [
				'shell:emptydist'
				'createSymlinks:dist'
				'replace:html' 				# Copy and replace index.html
				'cssmin:dist'
				'rsync:dist'
				'requirejs:compile' 	# Run r.js
				# 'shell:rsync'				# Rsync to test server			
			]
		,q
			# all
			aliases: ['all']
			tasks: ['compile', 'docs', 'build', 'sw']
	]

	for job in jobs
		for alias in job.aliases
			grunt.registerTask alias, job.tasks


	grunt.registerMultiTask 'createSymlinks', 'Creates a symlink', ->
		for own index, config of this.data
