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: https://github.com/nodejs/node/pull/2428 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Rod Vagg <rod@vagg.org>
This commit is contained in:
parent
1aa9d3a2ab
commit
a2e43412cf
@ -25,12 +25,9 @@ for (var i = 0; i < tokens.length; i++) {
|
|||||||
var token = tokens[i];
|
var token = tokens[i];
|
||||||
if (token.type === 'heading') {
|
if (token.type === 'heading') {
|
||||||
if (files && Object.keys(files).length !== 0) {
|
if (files && Object.keys(files).length !== 0) {
|
||||||
verifyFiles(files, function(err) {
|
verifyFiles(files,
|
||||||
if (err)
|
console.log.bind(null, 'wrote'),
|
||||||
console.log(err);
|
function(err) { if (err) throw err; });
|
||||||
else
|
|
||||||
console.log('done');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
files = {};
|
files = {};
|
||||||
} else if (token.type === 'code') {
|
} else if (token.type === 'code') {
|
||||||
@ -51,7 +48,7 @@ function once(fn) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyFiles(files, callback) {
|
function verifyFiles(files, onprogress, ondone) {
|
||||||
var dir = path.resolve(verifyDir, 'doc-' + id++);
|
var dir = path.resolve(verifyDir, 'doc-' + id++);
|
||||||
|
|
||||||
files = Object.keys(files).map(function(name) {
|
files = Object.keys(files).map(function(name) {
|
||||||
@ -78,17 +75,19 @@ function verifyFiles(files, callback) {
|
|||||||
fs.mkdir(dir, function() {
|
fs.mkdir(dir, function() {
|
||||||
// Ignore errors
|
// Ignore errors
|
||||||
|
|
||||||
|
var done = once(ondone);
|
||||||
var waiting = files.length;
|
var waiting = files.length;
|
||||||
for (var i = 0; i < files.length; i++)
|
files.forEach(function(file) {
|
||||||
fs.writeFile(files[i].path, files[i].content, next);
|
fs.writeFile(file.path, file.content, function(err) {
|
||||||
|
if (err)
|
||||||
|
return done(err);
|
||||||
|
|
||||||
var done = once(callback);
|
if (onprogress)
|
||||||
function next(err) {
|
onprogress(file.path);
|
||||||
if (err)
|
|
||||||
return done(err);
|
|
||||||
|
|
||||||
if (--waiting === 0)
|
if (--waiting === 0)
|
||||||
done();
|
done();
|
||||||
}
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user