Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gruntjs read from external json file

I am attempting to read in an external json file and use that in a custom task:

Inside initConfig

grunt.initConfig({
  env: grunt.file.readJSON("PATH"),
  ...
  ..
  .
});

// Registering a task
grunt.registerTask('Namehere', 'DescriptionHere', function () { 
  // HOW DO I GET AT THE "env" 

  "<%= env.environment %>" // Doesnt work just gives me the string literal "<%= environmentVars.environment %>"
});
like image 545
Mike Fielden Avatar asked May 17 '26 08:05

Mike Fielden


1 Answers

You're likely to use grunt.config.get("env") or grunt.config("env") for this purpose.

More info: http://gruntjs.com/api/grunt.config#grunt.config.get (thanks @Mike Fielden)

like image 190
gustavohenke Avatar answered May 18 '26 22:05

gustavohenke