Skip to content

Commit f2f0fe4

Browse 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

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

tools/doc/addon-verify.js

+15-16
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)