result
填充在函数exec
中,但它永远不会回到主线程......我做错了什么?
var Fiber, exec, execSync;
exec = require("child_process").exec;
Fiber = require('fibers');
execSync = function(cmd) {
var cmdExec, final;
cmdExec = function(cmd) {
var fiber,
_this = this;
fiber = Fiber.current;
exec(cmd, function(se, so, e) {
var result;
fiber.run();
result = se + so + e;
return result;
});
return Fiber["yield"]();
};
final = '';
Fiber(function() {
return cmdExec(cmd);
}).run();
return final;
};
console.log(execSync('ls ..'));