How to debug Gruntfile.js with log statements?

Gururaj picture Gururaj · Sep 25, 2013 · Viewed 15.6k times · Source

In my Gruntfile, how can I add log statements, to its processing, as in the following example?

 karma: {
        unit: {
            configFile: "<%= grunt.option('Debug') ? 'build/karma.conf.js' : '' %>",
            console.log(configFile),
            singleRun: true,
            browsers: ['PhantomJS']
        },
    }

Answer

Kyle Robinson Young picture Kyle Robinson Young · Sep 26, 2013

Gruntfiles are javascript so you can use console.log() where ever as long as it is valid javascript.

grunt.initConfig({
  karma: {
    unit: {
      configFile: 'build/karma.conf.js'
    }
  }
});
if (grunt.option('debug')) {
  console.log(grunt.config('karma.unit.configFile'));
}