Skip to content

Instantly share code, notes, and snippets.

@jdavisclark
Created January 18, 2012 16:43
Show Gist options
  • Select an option

  • Save jdavisclark/1633947 to your computer and use it in GitHub Desktop.

Select an option

Save jdavisclark/1633947 to your computer and use it in GitHub Desktop.
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