The options hash will now be printed like this when Grunt is running in verbose mode:
Options: ...snip..., key="[hidden]", ...snip...
Try it on your own! Just run: grunt --verbose
I freely admit that this code might be a bit confusing because of the mismatched API. By "mismatched", I mean that you assign a value like you normally would:
options.key = "My secret key";
But to read the value, you need to call a function:
{ key: options.key() }
There are a few reasons I went this route:
grunt.log.writeflags, which is used to print the hash of options when in verbose mode, uses JSON.stringify, so I needed to override the toJSON function. This meant I had to return an object.
This integrates nicely with the this.options Grunt function, which uses assignment
It meant I didn't have to rewire how this gets passed through the entire API
The 'key' property can still be set as an option, and this will still work
The key will still show up when enumerated, so it's easy to see that a value was set, even if you can't see what it was
He folks! This patch addresses issue #203.
The options hash will now be printed like this when Grunt is running in verbose mode:
Try it on your own! Just run:
grunt --verbose
I freely admit that this code might be a bit confusing because of the mismatched API. By "mismatched", I mean that you assign a value like you normally would:
But to read the value, you need to call a function:
There are a few reasons I went this route:
JSON.stringify
, so I needed to override the toJSON function. This meant I had to return an object.