Skip to content

Commit

Permalink
Add options to customize the notification message (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuss authored and SBoudrias committed Jun 13, 2016
1 parent d61bd9b commit 98aa7bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,18 @@ UpdateNotifier.prototype.notify = function (opts) {

opts = opts || {};

var message = '\n' + boxen('Update available ' + chalk.dim(this.update.current) + chalk.reset(' → ') + chalk.green(this.update.latest) + ' \nRun ' + chalk.cyan('npm i -g ' + this.packageName) + ' to update', {
opts.message = opts.message || 'Update available ' + chalk.dim(this.update.current) + chalk.reset(' → ') +
chalk.green(this.update.latest) + ' \nRun ' + chalk.cyan('npm i -g ' + this.packageName) + ' to update';

opts.boxenOpts = opts.boxenOpts || {
padding: 1,
margin: 1,
align: 'center',
borderColor: 'yellow',
borderStyle: 'round'
});
};

var message = '\n' + boxen(opts.message, opts.boxenOpts);

if (opts.defer === undefined) {
process.on('exit', function () {
Expand Down
13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ Default: `true`

Defer showing the notification to after the process has exited.

#### options.message

Type: `string`<br>
Default: [See the screen shot above](https://github.com/yeoman/update-notifier#update-notifier-)

The message that will be shown when an update is available.

### options.boxenOpts

Type: `object`<br>
Default: `{ padding: 1, margin: 1, borderColor: 'yellow', borderStyle: 'round' }` ([See the screen shot above](https://github.com/yeoman/update-notifier#update-notifier-))

The object that will be passed to [boxen](https://github.com/sindresorhus/boxen).

### User settings

Expand Down

0 comments on commit 98aa7bf

Please sign in to comment.