Skip to content

Commit

Permalink
allow for default extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Mar 18, 2023
1 parent 7a70429 commit 66f8792
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import notifier from 'node-notifier';
import cS from 'clean-stack';
import stripAnsi from 'strip-ansi';

import defaults from './defaults.js';
import notifyDefaults from './defaults.js';

import applyChalkStyles from './lib/applyChalkStyles.js';
import constructPrefix from './lib/constructPrefix.js';
Expand All @@ -20,11 +20,16 @@ import getDisplay from './lib/getDisplay.js';
@param {Object} [notification.error] An optional error object to log out
@param {Boolean} [notification.k = false] Send a desktop notification
*/
export default function notify (notification) {
export default function notify (notification, dflts = {}) {
if (!isObject(notification)) {
notify({ m: 'Input must be an object', d: 'error' });
}

/**
* Allow extension of defaults, useful for testing
*/
const defaults = { ...notifyDefaults, ...dflts };

const { m = '', v = '', d = '', error = false, k } = notification;

/**
Expand Down

0 comments on commit 66f8792

Please sign in to comment.