grunt-notify
grunt-notify copied to clipboard
Any chance of making this global versus project-specific?
I love it, but I'd like to be able to do npm install -g grunt-notify and not have to install it as a dependency on every project I'm on... mostly because I work with a lot of other devs on projects, and they may not all want the popup... thoughts?
Awesome idea. Any idea how to make that work? Grunt can only run code it knows about.
Yeah, no idea... :)
There would have to be some kind of global config (i.e. "watch this Gruntfile and/or task X") and you would have to have some kind of global callback any time a task finished. Grunt might have that, I dunno.
Maybe better to to have a localconfig.json file which is not checked in, and then read and parse this in the Gruntfile?
Example localconfig.json:
{
"notifications": true
}
Example code from Gruntfile.js:
module.exports = function (grunt) {
var localconfig = {};
try {
localconfig = require('./localconfig');
} catch (e) {
grunt.log.ok("No localconfig.json found. Using default config…");
}
if (localconfig.notifications) {
grunt.loadNpmTasks('grunt-notify'); // Or some other clever thing to do..
}
Another perhaps better alternative is to utilize the builtin option parser in Grunt, so you can pass a flag while starting it, i.e. grunt --no-notify server.
Example code in Gruntfile.js:
if (grunt.option('no-notify')) {
grunt.log.warn('Notifications disabled');
// …
}