4

Code:

karma: { 
   unit: { 
       if  ("<%= grunt.option('Release') %>" ) 
         {
          //do nothing 
         }
      else
        {
         configFile: 'build/karma.conf.js',
         singleRun: true,
         browsers: ['PhantomJS']
        }
   }
}

how to write correct if else statement in gruntfile.js. I am invoking the gruntfile.js using visual studio project file.

MichaC
  • 13,104
  • 2
  • 44
  • 56
Gururaj
  • 1,115
  • 2
  • 14
  • 17

1 Answers1

6

Gruntfiles are javascript so it needs to be valid javascript, such as:

karma: { 
  unit: (function() { 
    if (grunt.option('Release')) {
      return {};
    } else {
      return {
        configFile: 'build/karma.conf.js',
        singleRun: true,
        browsers: ['PhantomJS']
      };
    }
  }())
}
Kyle Robinson Young
  • 13,732
  • 1
  • 47
  • 38