grunt-notify icon indicating copy to clipboard operation
grunt-notify copied to clipboard

Any chance of making this global versus project-specific?

Open jakerella opened this issue 12 years ago • 3 comments

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?

jakerella avatar Jun 17 '13 19:06 jakerella

Awesome idea. Any idea how to make that work? Grunt can only run code it knows about.

dylang avatar Jun 17 '13 20:06 dylang

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.

jakerella avatar Jun 17 '13 22:06 jakerella

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');
    // …
  }

ruudud avatar Jul 16 '13 09:07 ruudud