gruntjs / grunt

Grunt: The JavaScript Task Runner
http://gruntjs.com/
Other
12.27k stars 1.5k forks source link

this.data is not available in non-multi-tasks #1226

Open tandrewnichols opened 9 years ago

tandrewnichols commented 9 years ago

If I do this in a Gruntfile:

module.exports = function(grunt) {
  grunt.registerTask('something', 'description', function() {
    console.log(this.data);
  });
  grunt.initConfig({
    something: {
      some: 'data'
    }
  });
};

the output is undefined. Instead, you have to do grunt.config('something.some') to get that. I think I understand why this works the way it does (data belongs to a target, not a task), but it also kind of feels like this should work, if for no other reason than that the API is consistent then.

hdngr commented 9 years ago

@vladikoff - Has anyone taken this yet? If no I'd like to.

Also, can you give me a little bit clearer idea of the behavior we want? Thanks.