summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-12-14 00:14:38 +0800
committerDaniel Bevenius <daniel.bevenius@gmail.com>2018-12-18 05:14:24 +0100
commit9190e4ecdf891892e479b0ef4b691252d4084806 (patch)
tree28a76c6a2959131c8a1ac1988ee3fe2a7c95894f /tools
parent3edc1c917b6f678b9146b99daf91cc478cd0e8c3 (diff)
downloadandroid-node-v8-9190e4ecdf891892e479b0ef4b691252d4084806.tar.gz
android-node-v8-9190e4ecdf891892e479b0ef4b691252d4084806.tar.bz2
android-node-v8-9190e4ecdf891892e479b0ef4b691252d4084806.zip
tools: make apilinks building more robust
1. Move the apilinks.json file into out/doc so it gets cleaned when running `make docclean` 2. When the apilinks.json generated is empty, throw a specific error so it's easier to understand what's wrong 3. Write to a file passed through CLI arguments instead writing to stdout in apilinks.js so the build process is more robust in the case of a bad binary PR-URL: https://github.com/nodejs/node/pull/25019 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/doc/apilinks.js6
-rw-r--r--tools/doc/generate.js9
2 files changed, 10 insertions, 5 deletions
diff --git a/tools/doc/apilinks.js b/tools/doc/apilinks.js
index c86db14338..9c23ae55c5 100644
--- a/tools/doc/apilinks.js
+++ b/tools/doc/apilinks.js
@@ -47,7 +47,9 @@ const tag = execSync(`git describe --contains ${hash}`).split('\n')[0] || hash;
// Extract definitions from each file specified.
const definition = {};
-process.argv.slice(2).forEach((file) => {
+const output = process.argv[2];
+const inputs = process.argv.slice(3);
+inputs.forEach((file) => {
const basename = path.basename(file, '.js');
// Parse source.
@@ -206,4 +208,4 @@ process.argv.slice(2).forEach((file) => {
}
});
-console.log(JSON.stringify(definition, null, 2));
+fs.writeFileSync(output, JSON.stringify(definition, null, 2), 'utf8');
diff --git a/tools/doc/generate.js b/tools/doc/generate.js
index 7ca47e2ae0..dd213a35a6 100644
--- a/tools/doc/generate.js
+++ b/tools/doc/generate.js
@@ -49,9 +49,12 @@ args.forEach(function(arg) {
} else if (arg.startsWith('--output-directory=')) {
outputDir = arg.replace(/^--output-directory=/, '');
} else if (arg.startsWith('--apilinks=')) {
- apilinks = JSON.parse(
- fs.readFileSync(arg.replace(/^--apilinks=/, ''), 'utf8')
- );
+ const linkFile = arg.replace(/^--apilinks=/, '');
+ const data = fs.readFileSync(linkFile, 'utf8');
+ if (!data.trim()) {
+ throw new Error(`${linkFile} is empty`);
+ }
+ apilinks = JSON.parse(data);
}
});