Console and desktop notifications for Node.js scripts.
bun i @archoleat/notifierUse bun i -D @archoleat/notifier if only development scripts import it.
This ES module targets Node.js scripts, not browser notifications. It uses
Node.js APIs and node-notifier; Bun is used for repository tooling and is
not required to import the package in Node.js. Desktop delivery depends on
the operating system and notification permissions. Automated fallback tests
do not guarantee that a notification will be visible on every host.
import { error, info, success, warning } from '@archoleat/notifier';
await info({ message: 'Build started.', hasTime: false });
await success({ message: 'Build finished.' });
await warning({ message: ['This message will be truncated.', { maxLength: 20 }] });
await error({ message: 'Build failed.', notificationMode: 'console' });All four functions accept the same options and return a Promise. Await the call so desktop notification failures can be handled by the caller.
Accepted options, shown separately from the executable example:
type Options = {
message: string | [string, { maxLength: number }];
hasTime?: boolean;
notificationMode?: 'console' | 'desktop' | 'multiple';
};-
messageis required. The tuple form truncates text tomaxLength. -
hasTimedefaults totrue; it affects console output only. -
notificationModedefaults to'console'. Use'desktop'for operating system notifications or'multiple'for both outputs.
Desktop mode uses the operating system's notification service and requires its notification permissions. Use console mode in CI and other environments without a desktop session.
On macOS without Rosetta, desktop notifications fall back to the system notification service. This fallback uses the host application's notification permissions and does not display custom icons.
Please read CONTRIBUTING to start contributing.
This project is licensed under the MIT license.