summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2019-10-14 23:15:28 -0700
committerRich Trott <rtrott@gmail.com>2019-10-15 13:22:41 -0700
commitf4f856b2381d10de48534e0de97df142f3e29994 (patch)
tree7247aa14bc8b894ab768af314d287eef3150b99a /tools
parent3ebaf6b9bc495e5931e0ef2cd0726e8b5ea3d0b1 (diff)
downloadandroid-node-v8-f4f856b2381d10de48534e0de97df142f3e29994.tar.gz
android-node-v8-f4f856b2381d10de48534e0de97df142f3e29994.tar.bz2
android-node-v8-f4f856b2381d10de48534e0de97df142f3e29994.zip
test: fix flaky doctool and test
Doctool tests have been failing a lot in CI on Win2008 R2. It appears async functions and callback-based functions are being used in combination such that the callback-based function cannot guarantee that it will invoke its callback. Convert the callback-based functions to async functions so we have one paradigm and reliable results. PR-URL: https://github.com/nodejs/node/pull/29979 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/doc/generate.js17
-rw-r--r--tools/doc/html.js4
2 files changed, 8 insertions, 13 deletions
diff --git a/tools/doc/generate.js b/tools/doc/generate.js
index 8e3e733e52..7be5f3f73f 100644
--- a/tools/doc/generate.js
+++ b/tools/doc/generate.js
@@ -67,7 +67,7 @@ if (!filename) {
}
-fs.readFile(filename, 'utf8', (er, input) => {
+fs.readFile(filename, 'utf8', async (er, input) => {
if (er) throw er;
const content = unified()
@@ -84,15 +84,10 @@ fs.readFile(filename, 'utf8', (er, input) => {
const basename = path.basename(filename, '.md');
- html.toHTML(
- { input, content, filename, nodeVersion },
- (err, html) => {
- const target = path.join(outputDir, `${basename}.html`);
- if (err) throw err;
- fs.writeFileSync(target, html);
- }
- );
+ const myHtml = await html.toHTML({ input, content, filename, nodeVersion });
+ const htmlTarget = path.join(outputDir, `${basename}.html`);
+ fs.writeFileSync(htmlTarget, myHtml);
- const target = path.join(outputDir, `${basename}.json`);
- fs.writeFileSync(target, JSON.stringify(content.json, null, 2));
+ const jsonTarget = path.join(outputDir, `${basename}.json`);
+ fs.writeFileSync(jsonTarget, JSON.stringify(content.json, null, 2));
});
diff --git a/tools/doc/html.js b/tools/doc/html.js
index 318feefe34..f4246a781c 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -63,7 +63,7 @@ const gtocHTML = unified()
const templatePath = path.join(docPath, 'template.html');
const template = fs.readFileSync(templatePath, 'utf8');
-async function toHTML({ input, content, filename, nodeVersion }, cb) {
+async function toHTML({ input, content, filename, nodeVersion }) {
filename = path.basename(filename, '.md');
const id = filename.replace(/\W+/g, '-');
@@ -87,7 +87,7 @@ async function toHTML({ input, content, filename, nodeVersion }, cb) {
HTML = HTML.replace('__ALTDOCS__', '');
}
- cb(null, HTML);
+ return HTML;
}
// Set the section name based on the first header. Default to 'Index'.