Basically, this code is not good:
| fs.readFile(filename,'utf8',async(er,input)=>{ |
| if(er)thrower; |
| |
| constcontent=unified() |
| .use(markdown) |
| .use(html.preprocessText) |
| .use(json.jsonAPI,{ filename }) |
| .use(html.firstHeader) |
| .use(html.preprocessElements,{ filename }) |
| .use(html.buildToc,{ filename, apilinks }) |
| .use(remark2rehype,{allowDangerousHTML: true}) |
| .use(raw) |
| .use(htmlStringify) |
| .processSync(input); |
| |
| constbasename=path.basename(filename,'.md'); |
| |
| constmyHtml=awaithtml.toHTML({ input, content, filename, nodeVersion }); |
| consthtmlTarget=path.join(outputDir,`${basename}.html`); |
| fs.writeFileSync(htmlTarget,myHtml); |
| |
| constjsonTarget=path.join(outputDir,`${basename}.json`); |
| fs.writeFileSync(jsonTarget,JSON.stringify(content.json,null,2)); |
| }); |
Issues with that:
- Async function set as a callback (unhandled)
- sync I/O calls inside an async function
unified is synchronously invoked still
This is all the direct result of f4f856b, which is the result of something else. In hindsight, I wish I payed a bit more attention in my review of that.
Unfortunately my focus is elsewhere, so someone else should probably try to clean this up.
Basically, this code is not good:
node/tools/doc/generate.js
Lines 70 to 93 in 5a042a6
Issues with that:
unifiedis synchronously invoked stillThis is all the direct result of f4f856b, which is the result of something else. In hindsight, I wish I payed a bit more attention in my review of that.
Unfortunately my focus is elsewhere, so someone else should probably try to clean this up.