 path = require('path')
-exec = require('child_process').exec
+fs = require('fs')
 lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet
 folderMount = (connect, point) -> connect.static path.resolve(point)
 

				files: ['src/**/*.html', 'src/**/*.coffee', 'src/**/*.js', 'src/**/*.less', 'spec/**/*.coffee']
				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')
		else
			done = @async()
			exec 'git rev-parse --verify HEAD', (err, stdout, stderr) ->
				if err
					grunt.log.writeln 'Failed to set version by git.'
					done()
					return
				grunt.config 'meta.commit', stdout.replace('\n', '')
				grunt.log.writeln 'Version set by git commit to: ' + grunt.config('meta.commit')
				done()

	grunt.loadNpmTasks 'grunt-contrib-connect'
	grunt.loadNpmTasks 'grunt-contrib-concat'

				options:
					replacements: [
						pattern: /src="(\.\.\/)?(?!http|\/|\/\/)/ig
						replacement: 'src="<%= resourceToken %>/<%= pacha.infrastructure.s3.bucket %>/<%= gitCommit %>/'
					,
						pattern: /href="(\.\.\/)?(?!http|\/|\/\/)/ig
						replacement: 'href="<%= resourceToken %>/<%= pacha.infrastructure.s3.bucket %>/<%= gitCommit %>/'
					]

		connect:
