Skip to content

Instantly share code, notes, and snippets.

@ralucas
Last active August 29, 2015 14:10
Show Gist options
  • Save ralucas/371df8c35b0f8a8b70ca to your computer and use it in GitHub Desktop.
Save ralucas/371df8c35b0f8a8b70ca to your computer and use it in GitHub Desktop.
Working Gruntfile
"devDependencies": {
"blanket": "^1.1.6",
"chai": "^1.9.2",
"grunt": "^0.4.5",
"grunt-bump": "0.0.16",
"grunt-concurrent": "^1.0.0",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-cssmin": "^0.10.0",
"grunt-contrib-imagemin": "^0.9.2",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "^0.6.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-jsdoc": "^0.6.1",
"grunt-mocha-test": "^0.12.4",
"grunt-node-inspector": "^0.1.5",
"grunt-nodemon": "^0.3.0",
"grunt-notify": "^0.4.1",
"jshint-stylish": "~0.1.3",
"load-grunt-config": "^0.16.0",
"load-grunt-tasks": "^1.0.0",
"mocha": "^2.0.1",
"open": "0.0.5",
"supertest": "^0.14.0",
"time-grunt": "^1.0.0"
}
/**
* npm install --save-dev the following (or see the package.json):
* grunt
* grunt-contrib-watch
* time-grunt
* load-grunt-tasks
* grunt-bump
* grunt-mocha-test
* grunt-jsdoc@beta
* grunt-contrib-jshint
* jshint-stylish
* grunt-notify
* grunt-contrib-uglify
* grunt-contrib-imagemin
* grunt-contrib-cssmin
* grunt-concurrent
* grunt-nodemon
* grunt-node-inspector
* open
* blanket
**/
'use strict';
module.exports = function (grunt) {
// Show elapsed time at the end
require('time-grunt')(grunt);
// Load all grunt tasks
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
bump: {
createTag: true,
push: true,
pushTo: 'upstream'
},
mochaTest: {
test: {
options: {
reporter: 'spec',
require: 'tests/coverage/blanket',
grep: grunt.option('grep'),
colors: true
},
src: ['tests/*.js']
},
coverage: {
options: {
reporter: 'html-cov',
quiet: true,
captureFile: 'tests/coverage/coverage.html'
},
src: ['tests/*.js']
}
},
jsdoc: {
dist: {
src: ['app/*'],
options: {
destination: 'docs',
configure: 'docs/conf.json'
}
}
},
jshint: {
options: {
jshintrc: '.jshintrc',
force: true,
reporter: require('jshint-stylish')
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['app/*']
}
},
watch: {
server: {
files: ['.rebooted'],
options: {
livereload: true
}
}
},
concurrent: {
dev: {
tasks: ['nodemon', 'node-inspector', 'watch'],
options: {
logConcurrentOutput: true
}
}
},
nodemon: {
dev: {
script: 'bin/www',
options: {
nodeArgs: [],
env: {
PORT: '3000'
},
cwd: __dirname,
ignore: ['node_modules/**'],
watch: ['server', 'models'],
ext: 'js, json, html'
// omit this property if you aren't serving HTML files and
// don't want to open a browser tab on start
callback: function (nodemon) {
nodemon.on('log', function (event) {
console.log(event.colour);
});
// opens browser on initial server start
nodemon.on('config:update', function () {
// Delay before server listens on port
setTimeout(function() {
require('open')('https://localhost:3000');
}, 1000);
});
// refreshes browser when server reboots
nodemon.on('restart', function () {
// Delay before server listens on port
setTimeout(function() {
require('fs').writeFileSync('.rebooted', 'rebooted');
}, 1000);
});
}
}
}
},
'node-inspector': {
custom: {
options: {
'web-port': 8080,
'web-host': '0.0.0.0',
'debug-port': 5858,
'save-live-edit': true,
'no-preload': false,
'stack-trace-limit': 50,
'hidden': []
}
}
}
});
// Default task.
grunt.registerTask('default', ['jshint', 'concurrent']);
grunt.registerTask('test', 'mochaTest');
grunt.registerTask('docs', 'jsdoc');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment