Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm working on an application that relies heavily on nodejs' filewatchers.

Now we found that IntelliJ's auto-save feature that writes to a file as you type / blur the window doesn't trigger nodejs filewatchers - at least not on mac.

The following simple test verifies this.

  • Create a file called file.txt
  • Create the following script in the same folder
  • Edit file.txt in IntelliJ or Webstorm
  • Nothing should be looked (where as if you edit the file in any other editor and save it you see change 0, change 1 etc.)

fs = require( "fs" );
i = 0;

fs.watch( "./file.txt", function(){
    i++;
    console.log( "change " + i );
});

Is there any workaround / way to make this work?

share|improve this question
add comment

1 Answer

The simplest way:

  1. Right-click your script and choose Run <my script>.js
  2. Edit your txt file and then hit Ctrl+S
  3. See the result in Run Tool window
share|improve this answer
    
That works for the very first change, but subsequent changes don't trigger the filewatcher anymore –  wolframhempel Jun 6 '13 at 11:34
    
works for me - all changes trigger the watcher (if I keep it running, of course) –  lena Jun 6 '13 at 13:47
    
Hm. On mac or windows? This seems to be a mac only problem. Also are you using IntelliJ or Webstorm? –  wolframhempel Jun 6 '13 at 20:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.