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

Change defaults for reporter #109

Open
jorenmartijn opened this issue Jun 7, 2016 · 3 comments
Open

Change defaults for reporter #109

jorenmartijn opened this issue Jun 7, 2016 · 3 comments

Comments

@jorenmartijn
Copy link

Hi,

I'd like to be able to set my notification icon globally so I don't have to pass it through the .pipe(notify()) command in my gulp file.
Is there anyway I can do that? I found the defaults object in the reporter.js file, but can't figure out how to manipulate that from the gulp file.

Regards,
Joren

@mikaelbr
Copy link
Owner

mikaelbr commented Jun 7, 2016

Hi, @jorenmartijn! I think maybe extracting the usage to your own function which returns the notify object with default options is the "best practise" way to solve this.

@jorenmartijn
Copy link
Author

jorenmartijn commented Jun 7, 2016

Thanks for the quick response! Using your suggestion I wrote the following, which seems to work perfectly :)

function notice(options){
    var params = options;
    params['icon'] = path.join(__dirname, "favicon.png");
    return notify(params);
}

Regards,
Joren

@mikaelbr
Copy link
Owner

mikaelbr commented Jun 7, 2016

Good! Note, though, this mutates the object that you passed in. This means that if you send in the same object across several functions, they have the same changes. You can use something like lodash.assign, some extend implementation or just Object.assign if you are running Node 6 to avoid mutation. For instance:

function notice(options){
    return notify(Object.assign({}, options, {
        icon: path.join(__dirname, "favicon.png")
    });
}

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

No branches or pull requests

2 participants