Skip to content

Instantly share code, notes, and snippets.

@jamesshore
Last active January 3, 2016 19:39
Show Gist options
  • Save jamesshore/8510037 to your computer and use it in GitHub Desktop.
Save jamesshore/8510037 to your computer and use it in GitHub Desktop.
Michal Svoboda's port of [Automatopia](https://github.com/jamesshore/automatopia) to Grunt. See [this comment thread](http://www.letscodejavascript.com/v3/comments/lab/1#comment-1206272962) for context.
/* global module */
(function() {
"use strict";
module.exports = function(grunt) {
var shellOptions = { stdout: true, stderr: true, failOnError: true };
grunt.initConfig({
jshint: {
client: { options: { jshintrc: true }, src: ['client/*.js'] },
server: { options: { jshintrc: true }, src: ['server/*.js'] },
configs: { options: { jshintrc: true }, src: ['Gruntfile.js', 'karma.conf.js'] }
},
shell: {
karmaRun: { options: shellOptions, command: 'node_modules/karma/bin/karma run' },
karmaStart: { options: shellOptions, command: 'node_modules/karma/bin/karma start' },
gitStatus: { options: shellOptions, command: './cleanstatus.sh' },
runServer: { options: shellOptions, command: 'node server/start_server.js' }
}, browserify: {
dist: {
files: { 'dist/app.js': ['client/client.js'] },
options: { alias: ['client/client.js:client'] }
}
},
copy: {
dist: {
files: [
{ src: ['client/*.html', 'client/lib/*.js'], dest: 'dist/', flatten: true, expand: true }
]
}
},
clean: { dist: ['dist'] },
nodeunit: { server: ['server/_*_test.js'] }
});
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.registerTask('build', 'Build dist bundle', [ 'clean:dist', 'browserify:dist', 'copy:dist']);
grunt.registerTask('default', 'Lint & test', ['jshint', 'shell:karmaRun', 'build', 'nodeunit:server' ]);
grunt.registerTask('integrate', 'Git status & lint & test', ['shell:gitStatus', 'default']);
grunt.registerTask('karma', 'Start karma server', [ 'shell:karmaStart' ]);
grunt.registerTask('server', 'Start http server', [ 'shell:runServer' ]);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment