How to place if else block in gruntfile.js
Asked Answered
P

1

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.

Polychasium answered 25/9, 2013 at 16:39 Comment(0)
D
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']
      };
    }
  }())
}
Dependence answered 25/9, 2013 at 22:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.