Skip to content

Instantly share code, notes, and snippets.

@jslatts
Created June 19, 2011 23:46
Show Gist options
  • Save jslatts/1034914 to your computer and use it in GitHub Desktop.
Save jslatts/1034914 to your computer and use it in GitHub Desktop.
vows.js async callback state example
'file remove in watched dir': {
topic: function () {
var lPath = tPath + '/t2';
try {
fs.mkdirSync(lPath, '0755');
}
catch (Exception) {}
return lPath;
},
'calling stalker.watch': {
topic: function (lPath) {
var that = this;
stalker.watch(lPath,
function(err, file) {
setTimeout(function() {
fs.unlink(file);
}, 1000);
}, function (err, file) {
that.callback(err, file, lPath);
});
var rPath = lPath + '/temp';
var tStream = fs.createWriteStream(rPath);
tStream.end('fancy test file', 'utf8');
},
'fires second callback': function (err, file, lPath) {
assert.isNull(err);
assert.equal(file, lPath + '/temp');
fs.rmdirSync(lPath);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment