You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
536 B

4 years ago
  1. var net = require('net');
  2. var hasGrowl = false;
  3. module.exports = function(growlConfig, cb) {
  4. if (typeof cb === 'undefined') {
  5. cb = growlConfig;
  6. growlConfig = {};
  7. }
  8. if (hasGrowl) return cb(null, hasGrowl);
  9. var port = growlConfig.port || 23053;
  10. var host = growlConfig.host || 'localhost';
  11. var socket = net.connect(port, host);
  12. socket.setTimeout(100);
  13. socket.on('connect', function() {
  14. socket.end();
  15. cb(null, true);
  16. });
  17. socket.on('error', function() {
  18. socket.end();
  19. cb(null, false);
  20. });
  21. };