非同期パラダイムをまだ理解していないかもしれませんが、次のようなことをしたいと思います。
var exec, start;
exec = require('child_process').exec;
start = function() {
return exec("wc -l file1 | cut -f1 -d' '", function(error, f1_length) {
return exec("wc -l file2 | cut -f1 -d' '", function(error, f2_length) {
return exec("wc -l file3 | cut -f1 -d' '", function(error, f3_length) {
return do_something_with(f1_length, f2_length, f3_length);
});
});
});
};
新しいシェルコマンドを追加するたびにこれらのコールバックをネストし続けるのは少し奇妙に思えます。それを行うためのより良い方法はありませんか?