/**
 * elemon.js
 * 
 * Copyright (c) 2016 Mawni Maghsoudlou
 * Released under the MIT license
 */

/**
 * elemon is a live-reload tool for developing electron application.
 * It monitors an electron application during development and
 * automatically reloads it upon any changes.
 */

'use strict';
const chok = require('chokidar');
const path = require('path');

function elemon(main, wins) {
  var watch_opts = {
    ignored: [/[\/\\]\./, 'node_modules', '.git'],
    persistent: true
  };
  var watcher = chok.watch('.', watch_opts);
  watcher.on('change', (f) => {
    if (main.app && main.res && main.res === f) {
      main.app.relaunch();
      main.app.exit(0);
    } else {
      if (wins && Array.isArray(wins) && wins.length > 0) {
        wins.forEach((win) => {
          if (win.bw && win.res && Array.isArray(win.res) && win.res.indexOf(path.basename(f)) !== -1) {
            win.bw.reload();
          }
        });
      }
    }
  });
}
module.exports = elemon;

@@ -12,17 +12,16 @@
 on.js%0A *
- 
 %0A * Copy
@@ -290,17 +290,16 @@
  strict'
-;
 %0Aconst c
@@ -323,17 +323,16 @@
 okidar')
-;
 %0Aconst p
@@ -352,17 +352,16 @@
 ('path')
-;
 %0A%0Afuncti
@@ -369,16 +369,17 @@
 n elemon
+ 
 (main, w
@@ -396,18 +396,17 @@
 ar watch
-_o
+O
 pts = %7B%0A
@@ -480,17 +480,16 @@
 true%0A  %7D
-;
 %0A  var w
@@ -522,15 +522,13 @@
 atch
-_o
+O
 pts)
-;
 %0A  w
@@ -631,17 +631,16 @@
 launch()
-;
 %0A      m
@@ -654,17 +654,16 @@
 .exit(0)
-;
 %0A    %7D e
@@ -892,17 +892,105 @@
 reload()
-;
+%0A          %7D else if (win.bw && win.res && win.res === '*') %7B%0A            win.bw.reload()
 %0A       
@@ -1004,17 +1004,16 @@
       %7D)
-;
 %0A      %7D
@@ -1023,17 +1023,16 @@
   %7D%0A  %7D)
-;
 %0A%7D%0Amodul
@@ -1053,6 +1053,5 @@
 emon
-;
 %0A

allow general folder watch