Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure key option isn't printed to console #204

Merged
merged 1 commit into from
Jun 29, 2016
Merged

Conversation

Nycto
Copy link
Contributor

@Nycto Nycto commented Jan 26, 2016

He folks! This patch addresses issue #203.

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:

  1. 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.
  2. This integrates nicely with the this.options Grunt function, which uses assignment
  3. It meant I didn't have to rewire how this gets passed through the entire API
  4. The 'key' property can still be set as an option, and this will still work
  5. 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

@Jonahss
Copy link
Collaborator

Jonahss commented Jun 29, 2016

Good one, thoroughly impressed :)

@Jonahss Jonahss merged commit 7deed62 into axemclion:master Jun 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants