node-notifier
Version:
A Node.js module for sending notifications on native Mac, Windows (post and pre 8) and Linux (or Growl as fallback)
25 lines (24 loc) • 651 B
JavaScript
import net from "node:net";
// src/lib/checkGrowl.ts
function checkGrowl(growlConfig, cb) {
if (typeof growlConfig === "function") {
cb = growlConfig;
growlConfig = {};
}
const callback = cb;
const port = growlConfig.port || 23053;
const host = growlConfig.host || "localhost";
const socket = net.connect(port, host);
socket.setTimeout(100);
let done = false;
const finish = (hasGrowl) => {
if (done) return;
done = true;
socket.end();
callback(null, hasGrowl);
};
socket.once("connect", () => finish(true));
socket.once("error", () => finish(false));
}
export { checkGrowl as default };
//# sourceMappingURL=checkGrowl.js.map