title: Node.js fs.watch - outputs multiple times for single change
body: <p>I am creating a local app that uses node.js on windows.  the idea is to watch a specific file and send the contents to the browser when the file changes.</p>
  
  <p>right now, for testing, I am just looking at the fs.watch on the file from the console.  What I have noticed is that a single change to the file I am watching creates double output to the console.</p>
  
  <p>here is the server:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>var fs, http, io, server;
  fs = require('fs');
  http = require('http');
  server = http.createServer(function(req, res) {
    return fs.readFile("" + __dirname + "/socket.io.demo.html", function(err, data) {
      res.writeHead(200, {
        'Content-Type': 'text/html'
      });
      return res.end(data, 'utf8');
    });
  });
  server.listen(1337);
  
  fs.watch('/', function (event, filename) {
    console.log('event is: ' + event);
    if ('test.txt') {
      console.log('filename provided: ' + filename);
    } else {
      console.log('filename not provided');
    }
  });
  
  io = require('socket.io').listen(server);
  io.sockets.on('connection', function(socket) {
    socket.on('publish', function(message) {
      return io.sockets.send(message);
    });
    socket.on('broadcast', function(message) {
      return socket.broadcast.send(message);
    });
    return socket.on('whisper', function(message) {
      return socket.broadcast.emit('secret', message);
    });
  });
  </code></pre>
  
  <p>here is the html:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Socket.IO demo&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;Socket.IO demo&lt;/h1&gt;
      &lt;input type="text" autofocus="autofocus" /&gt;
      &lt;button type="button"&gt;publish&lt;/button&gt;
      &lt;button type="button"&gt;broadcast&lt;/button&gt;
      &lt;button type="button"&gt;whisper&lt;/button&gt;
      &lt;p&gt;Status: &lt;span id="status"&gt;Undefined&lt;/span&gt;&lt;/p&gt;
      &lt;ol id="messages"&gt;&lt;/ol&gt;
      &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
      &lt;script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js"&gt;&lt;/script&gt;
      &lt;script type="text/coffeescript"&gt;
  
        jQuery ($) -&gt;
  
          $status = $ '#status'
          socket = io.connect()
  
          socket.on 'connect', -&gt;
            $status.text 'Connected'
  
          socket.on 'disconnect', -&gt;
            $status.text 'Disconnected'
  
          socket.on 'reconnecting', (seconds) -&gt;
            $status.text "Reconnecting in #{seconds} seconds"
  
          socket.on 'reconnect', -&gt;
            $status.text 'Reconnected'
  
          socket.on 'reconnect_failed', -&gt;
            $status.text 'Failed to reconnect'
  
          socket.on 'message', (message) -&gt;
            $('&lt;li&gt;').text(message).appendTo $('#messages')
  
          socket.on 'secret', (message) -&gt;
            console.log message
  
          $input = $ 'input'
  
          $('button').click -&gt;
            socket.emit $(this).text(), $input.val()
            $input.val('').focus()
  
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any thoughts on why fs.watch is creating double output in the console?</p>