refactor out duplication in grunt/tasks