与Commander的兼容性问题
xingrz opened this issue · 0 comments
xingrz commented
Command.js的.choose(list, fn)
方法,直接fromCallback
绑定会报TypeError: undefined is not a function
(似乎是回调fn没有传过去),但像下面那样自己包多一层function就没事。
var program = require('commander');
var Wind = require('wind'),
Binding = Wind.Async.Binding;
/* this dosen't work */
program.chooseAsync = Binding.fromCallback(program.choose);
/* this does work */
/*program.chooseAsync = Binding.fromCallback(function(list, fn) {
program.choose(list, fn);
});*/
eval(Wind.compile('async', function () {
var list = ['javascript', '.net', 'php', 'ruby', 'python'];
var choise = $await(program.chooseAsync(list));
console.log('you just chose: %s', choise);
}))().start();