 	grunt.registerTask 'test', ['dev', 'jasmine']
 	grunt.registerTask 'test-watch', ['test', 'regarde:test']
 
+	# Generates version folder
+	grunt.registerTask 'gen-version', ->
+		env = this.args[0] or 'dev'
+		console.log 'Deploying to environment:', env
+		grunt.config 'meta.env', env
+		grunt.task.run ['set-version', 'copy:env', 'string-replace:deploy']
+	
 	# Deploy - creates deploy folder structure
 	grunt.registerTask 'deploy', ->
 		env = this.args[0] or 'dev'
-		grunt.task.run ['prod', 'jasmine', 'set-env:' + env, 'deploy-version', 'copy:deploy', 'copy:env', 'token', 'string-replace:deploy']
-
+		grunt.task.run ['prod', 'jasmine', 'gen-version:' + env, 'copy:deploy']
+		
 	# Example usage of deploy task
 	grunt.registerTask 'deploy-example', ['deploy:master']
 


			env:
				expand: true
				cwd: 'deploy/<%= meta.commit %>/'
				src: ['index.html', 'index.debug.html']
				dest: 'deploy/<%= meta.env %>/'


				tasks: ['test']
				spawn: true

	# Looks for the commit hash in a GIT_COMMIT env var, or tries calling git.
	grunt.registerTask 'set-version', ->
		if process.env.GIT_COMMIT
			grunt.config 'meta.commit', new String(process.env.GIT_COMMIT)
			grunt.log.writeln 'Version set by environment variable GIT_COMMIT to: ' + grunt.config('meta.commit')
