Skip to content

Instantly share code, notes, and snippets.

@DanilloCorvalan
Last active August 29, 2015 13:56
Show Gist options
  • Save DanilloCorvalan/9140163 to your computer and use it in GitHub Desktop.
Save DanilloCorvalan/9140163 to your computer and use it in GitHub Desktop.
gist for stackoverflow question
'use strict';
module.exports = function(grunt) {
// Project Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
js: {
files: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'],
tasks: ['jshint'],
options: {
livereload: true,
},
},
html: {
files: ['public/views/**', 'app/views/**'],
options: {
livereload: true,
},
},
css: {
files: ['public/css/**'],
options: {
livereload: true
}
},
test: {
files: ['app/**/*.js', 'test/mocha/**/*.js'],
tasks: ['mochaTest']
}
},
jshint: {
all: {
src: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js', '!test/coverage/**/*.js'],
options: {
jshintrc: true
}
}
},
nodemon: {
dev: {
script: 'server.js',
options: {
args: [],
ignore: ['public/**'],
ext: 'js',
nodeArgs: ['--debug'],
delayTime: 1,
env: {
PORT: 3000
},
cwd: __dirname
}
}
},
concurrent: {
tasks: ['nodemon', 'watch'],
options: {
logConcurrentOutput: true
}
},
mochaTest: {
options: {
reporter: 'spec',
require: 'server.js'
},
src: ['test/mocha/**/*.js']
},
env: {
test: {
NODE_ENV: 'test'
}
},
karma: {
unit: {
configFile: 'test/karma/karma.conf.js'
}
}
});
//Load NPM tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-env');
//Making grunt default to force in order not to break the project.
grunt.option('force', true);
//Default task(s).
grunt.registerTask('default', ['jshint', 'concurrent']);
//Test tasks.
grunt.registerTask('test', ['env:test', 'mochaTest', 'karma:unit']);
grunt.registerTask('test-w', ['env:test', 'jshint:all', 'mochaTest', 'karma:unit', 'watch:test']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment