markdown-word
markdown-word copied to clipboard
file not readable
Hi,
tried to convert this MD to word: http://codemirror.net/mode/markdown/
got an unreadable File, no error, is there a debug switch?
regards
The problem is in line 789, where fs.writeFile is called, but the callback is an empty function. The solution could be to use fs.writeFileSync, or to refactor to handle the callback of the async call correctly.
https://github.com/Trimeego/markdown-word/blob/master/lib/markdown-word.js#L789
return buff = archive.toBuffer(function(result) {
return fs.writeFile(outputFile, result, function() {});
});
What happens is the callback does nothing, so your program continues and when it tries to use the file this function creates, it is too early because it didn't wait for the callback from writeFile so the file does not exist yet.