Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f2f0fe4

Browse filesBrowse files
bnoordhuisrvagg
authored andcommitted
tools: make add-on scraper print filenames
Make the tool that generates add-ons from doc/api/addons.markdown print the names of the files it writes out. Before this commit, it printed a rather unhelpful "Done." PR-URL: #2428 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent 944174b commit f2f0fe4
Copy full SHA for f2f0fe4

File tree

Expand file treeCollapse file tree

1 file changed

+15
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-16
lines changed
Open diff view settings
Collapse file

‎tools/doc/addon-verify.js‎

Copy file name to clipboardExpand all lines: tools/doc/addon-verify.js
+15-16Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ for (var i = 0; i < tokens.length; i++) {
2525
var token = tokens[i];
2626
if (token.type === 'heading') {
2727
if (files && Object.keys(files).length !== 0) {
28-
verifyFiles(files, function(err) {
29-
if (err)
30-
console.log(err);
31-
else
32-
console.log('done');
33-
});
28+
verifyFiles(files,
29+
console.log.bind(null, 'wrote'),
30+
function(err) { if (err) throw err; });
3431
}
3532
files = {};
3633
} else if (token.type === 'code') {
@@ -51,7 +48,7 @@ function once(fn) {
5148
};
5249
}
5350

54-
function verifyFiles(files, callback) {
51+
function verifyFiles(files, onprogress, ondone) {
5552
var dir = path.resolve(verifyDir, 'doc-' + id++);
5653

5754
files = Object.keys(files).map(function(name) {
@@ -78,17 +75,19 @@ function verifyFiles(files, callback) {
7875
fs.mkdir(dir, function() {
7976
// Ignore errors
8077

78+
var done = once(ondone);
8179
var waiting = files.length;
82-
for (var i = 0; i < files.length; i++)
83-
fs.writeFile(files[i].path, files[i].content, next);
80+
files.forEach(function(file) {
81+
fs.writeFile(file.path, file.content, function(err) {
82+
if (err)
83+
return done(err);
8484

85-
var done = once(callback);
86-
function next(err) {
87-
if (err)
88-
return done(err);
85+
if (onprogress)
86+
onprogress(file.path);
8987

90-
if (--waiting === 0)
91-
done();
92-
}
88+
if (--waiting === 0)
89+
done();
90+
});
91+
});
9392
});
9493
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.