如何在回调完成后触发最终的console.log
var nodePandoc = require('node-pandoc');
var src, args;
src = 'Lesson.docx';
args = '-f docx -t markdown -o ./Lesson.md';
callback = function (err, result) {
if (err) console.error('Oh No: ',err);
return console.log("callback result:",result), result;
};
nodePandoc(src, args, callback);
console.log("Conversion finished, you can call function to move the file around");
最简单的方法是从回调中记录最后一行:
var nodePandoc = require('node-pandoc');
var src, args;
src = 'Lesson.docx';
args = '-f docx -t markdown -o ./Lesson.md';
callback = function (err, result) {
if (err) return console.error('Oh No: ',err);
console.log("callback result:",result);
console.log("Conversion finished, you can call function to move the file around");
};
nodePandoc(src, args, callback);