Skip to content

Instantly share code, notes, and snippets.

@ebourmalo
Last active August 29, 2015 14:26
Show Gist options
  • Save ebourmalo/d3756bcd844c5eab7053 to your computer and use it in GitHub Desktop.
Save ebourmalo/d3756bcd844c5eab7053 to your computer and use it in GitHub Desktop.
Grunt configuration for using nodemon and output logs with Bunyan
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.registerTask('default', 'concurrent:dev');
grunt.initConfig({
concurrent: {
dev: {
tasks: ['nodemon:dev', 'watch:js', 'watch:sass'],
options: {
logConcurrentOutput: true
}
}
},
watch: {
options: {
atBegin: true,
spawn: false,
interval: 1500
},
sass: {
files: ['theme/scss/**', 'theme/images/**'],
tasks: ['compass:dist', 'copy:images']
},
js: {
files: ['theme/templates/**', 'front/**/*'],
tasks: ['ngtemplates:ideation', 'concat:dev'],
options: {
interval: 500
}
}
},
nodemon: {
dev: {
script: 'index.js',
options: {
stdout: false,
watch: ['app'],
callback: function (nodemon) {
var bunyan;
nodemon.on('readable', function () {
// free memory
// bunyan && bunyan.kill()
bunyan = grunt.util.spawn({
cmd: './node_modules/bunyan/bin/bunyan',
args: ['--output', 'short', '--color']
}, function() {});
bunyan.stdout.pipe(process.stdout);
bunyan.stderr.pipe(process.stderr);
this.stdout.pipe(bunyan.stdin);
this.stderr.pipe(bunyan.stdin);
});
}
}
}
}
});
};
@ebourmalo
Copy link
Author

Update for providing a done callback for the spawn process (http://gruntjs.com/api/grunt.util#grunt.util.spawn)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment