All files main.js

76.47% Statements 13/17
61.54% Branches 8/13
50% Functions 1/2
76.47% Lines 13/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 341x 1x 1x   1x 169x         165x     4x   4x     4x   4x           4x     4x     1x  
const execSync = require('child_process').execSync;
const os = require('os');
const user = os.userInfo().username;
 
const notify = (text, executeTime) => {
  if (
    typeof text !== 'string' ||
    typeof executeTime !== 'string' ||
    !Boolean(/^((\d*))$/.exec(executeTime))
  ) {
    return false;
  }
 
  const opsys = process.platform;
  let commandMessage;
  Iif (opsys == 'darwin') {
    // MacOS
    commandMessage = 'osascript -e';
  } else Eif (opsys == 'win32' || opsys == 'win64') {
    // Windows
    commandMessage = 'msg';
  } else if (opsys == 'linux') {
    // Linux
    commandMessage = `export DISPLAY=':0.0' && xmessage`;
  }
  let otputControl;
  setTimeout(() => {
    execSync(`${commandMessage} ${user} ${text}`);
  }, executeTime);
  return otputControl;
};
 
module.exports = { notify };