Created
October 30, 2011 19:34
-
-
Save peterwmwong/1326322 to your computer and use it in GitHub Desktop.
fs.watch/fs.writeFileSync win vs ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node lib/test.js | |
fs.writeFileSync: /tmp/test.txt | |
fs.watch: /tmp/test.txt | |
fs.writeFileSync: /tmp/test.txt | |
>> fs.watch CALLBACK: change test.txt | |
FSWatcher.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\projects\test>node test.js | |
fs.writeFileSync: C:\Users\pwong\AppData\Local\Temp\test.txt | |
fs.watch: C:\Users\pwong\AppData\Local\Temp\test.txt | |
fs.writeFileSync: C:\Users\pwong\AppData\Local\Temp\test.txt | |
>> fs.watch CALLBACK: change test.txt | |
>> fs.watch CALLBACK: change test.txt | |
FSWatcher.close() | |
>> fs.watch CALLBACK: change null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"), | |
file = require("path").resolve((process.env.TEMP || "/tmp") + "/test.txt"), | |
L = console.log.bind(console); | |
L("fs.writeFileSync: ",file); | |
fs.writeFileSync(file, ""); | |
L("fs.watch:",file); | |
var tmpw = fs.watch(file, function(ev,fname){ | |
L(">> fs.watch CALLBACK:", ev, fname); | |
}); | |
setTimeout(function(){ | |
L("fs.writeFileSync:", file); | |
fs.writeFileSync(file, "one"); | |
},100); | |
setTimeout(function(){ | |
L("FSWatcher.close()"); | |
tmpw.close(); | |
}, 1000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment