Inconsistency between node and atom-shell behavior


#1

Update

Interestingly, the code below also works when run on client (is it called browser?) side

var fs = require('fs')

fs.watch('./ACTIVE.MD', {
  persistent: true
}, function(event, filename) {
  console.log(event + ' EVENT ON ' + filename ); // actually logs changes 
});

I suppose that the moral of the story is, at least for now, do file watching on the client side.

Original

This file watching code works under node

var fs = require('fs')

fs.watch('./ACTIVE.MD', {
  persistent: true
}, function(event, filename) {
  console.log(event + ' EVENT ON ' + filename ); // actually logs changes 
});

this, very similar code does not work with atom-shell… (server side)


send = function(win, msg) {
    win.webContents.on('did-finish-load', function() {
        win.webContents.send('send-console', msg);
    });
}

app.on('ready', function() {
  mainWindow = new BrowserWindow({width: 800, height: 600});

  mainWindow.loadUrl('file://' + __dirname + '/index.html');
send(mainWindow, 'ABSOLUTE STARTING PATH IS : ' + path.resolve('.'))
fs.watch('./ACTIVE.MD', {
  persistent: true
}, function(event, filename) {
  send(mainWindow, event + ' EVENT ON ' + filename ); // does not send the messages ...
});

  mainWindow.on('closed', function() {
    mainWindow = null;
  });
   mainWindow.toggleDevTools();
})

for the sake of completeness, this is the client side js

require('ipc').on('send-console', function(msg) {
    console.log(msg);
});

Browser and Node integration concepts