How to use the node-notifier/lib/utils.js.immediateFileCommand function in node-notifier

To help you get started, we’ve selected a few node-notifier examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeit / pkg / test / test-79-npm / node-notifier / node-notifier.js View on Github external
'use strict';

var fs = require('fs');
var path = require('path');
var notifier = require('node-notifier');
var utils = require('node-notifier/lib/utils.js');
var whichArgument;

utils.command = utils.fileCommandJson = utils.immediateFileCommand = function (filename) {
  var forLinux = filename === whichArgument; // 'notify-send' is built-in on linux
  var forNonLinux = (fs.existsSync(filename) && path.isAbsolute(filename));
  if ((forLinux || forNonLinux) &&
       filename.indexOf('snapshot') < 0) {
    console.log('ok');
  }
  process.exit();
};

var which = require('which');
which.sync = function (filename) {
  whichArgument = filename;
  return true;
};

notifier.notify('hi!');