Created
January 18, 2012 16:43
-
-
Save jdavisclark/1633947 to your computer and use it in GitHub Desktop.
promise tests with https://github.com/mde/jake
This file contains hidden or 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"), | |
| qPromise = require('q'), | |
| pioPromise = require('promised-io/promise'); | |
| pioPromise.node = pioPromise.convertNodeAsyncFunction; | |
| // var q = qPromise; // calls to 'fail' do nothing | |
| var q = pioPromise; // calls to fail work fine | |
| desc("promise async test task"); | |
| task("default", [], function() { | |
| q.node(fs.readdir)("/").then(function(dirs) { | |
| console.log(dirs.slice(0,3).join()); // always works, regardless of promise library | |
| fail("fail in success"); // works with promised-io, does nothing with q | |
| }, function(err) { | |
| fail("fail in reject"); // readdir always succeeds, we never get here. | |
| }); | |
| }, {async: true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment