Skip to content

Instantly share code, notes, and snippets.

@msuarz
Created July 27, 2015 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msuarz/ef3af5d438a2e1987940 to your computer and use it in GitHub Desktop.
Save msuarz/ef3af5d438a2e1987940 to your computer and use it in GitHub Desktop.
Go Grunt
loadTasks = require 'load-grunt-tasks'
module.exports = (grunt) ->
env = process.env
cwd = process.cwd()
root = "#{cwd}/../../go"
src = "#{root}/src/#{env.src}"
command = (cmd, opts) ->
command: cmd
options:
execOptions: opts
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
env:
go:
GOPATH: root
PATH: "#{env.PATH}:#{root}/bin"
watch:
go:
files: ['../**/*.go']
tasks: ['shell:sync', 'shell:test']
shell:
env: command: 'env'
clean: command: "rm -Rf #{root}"
source: command: "mkdir -p #{src}"
sync: command: "rsync -ar ../ #{src}/ --exclude ci"
get: command("go get -v -t ./...", cwd: src)
test: command("go test -v ./...", cwd: src)
loadTasks grunt
grunt.option 'force', true
grunt.registerTask 'install', ['env:go', 'shell:clean', 'shell:source', 'shell:sync', 'shell:get']
grunt.registerTask 'test', ['env:go', 'shell:test']
grunt.registerTask 'echo', ['env:go', 'shell:env']
grunt.registerTask 'default', ['env', 'watch:go']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment