Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: fix tools/addon-verify.js #14048

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,6 @@ The following `addon.cc` implements AtExit:

```cpp
// addon.cc
#undef NDEBUG
#include <assert.h>
#include <stdlib.h>
#include <node.h>
Expand Down Expand Up @@ -1110,10 +1109,10 @@ static void sanity_check(void*) {
}

void init(Local<Object> exports) {
AtExit(sanity_check);
AtExit(at_exit_cb2, cookie);
AtExit(at_exit_cb2, cookie);
AtExit(at_exit_cb1, exports->GetIsolate());
AtExit(sanity_check);
}

NODE_MODULE(addon, init)
Expand All @@ -1125,7 +1124,7 @@ Test in JavaScript by running:

```js
// test.js
const addon = require('./build/Release/addon');
require('./build/Release/addon');
```

[Embedder's Guide]: https://github.com/v8/v8/wiki/Embedder's%20Guide
Expand Down
36 changes: 18 additions & 18 deletions tools/doc/addon-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ const verifyDir = path.resolve(rootDir, 'test', 'addons');
const contents = fs.readFileSync(doc).toString();

const tokens = marked.lexer(contents);
let files = null;
let id = 0;

// Just to make sure that all examples will be processed
tokens.push({ type: 'heading' });

for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
let currentHeader;
const addons = {};
tokens.forEach((token) => {
if (token.type === 'heading' && token.text) {
const blockName = token.text;
if (files && Object.keys(files).length !== 0) {
verifyFiles(files,
blockName,
console.log.bind(null, 'wrote'),
function(err) { if (err) throw err; });
}
files = {};
} else if (token.type === 'code') {
currentHeader = token.text;
addons[currentHeader] = {
files: {}
};
}
if (token.type === 'code') {
var match = token.text.match(/^\/\/\s+(.*\.(?:cc|h|js))[\r\n]/);
if (match === null)
continue;
files[match[1]] = token.text;
if (match !== null) {
addons[currentHeader].files[match[1]] = token.text;
}
}
});
for (var header in addons) {
verifyFiles(addons[header].files,
header,
console.log.bind(null, 'wrote'),
function(err) { if (err) throw err; });
}

function once(fn) {
Expand Down