Skip to content

Commit

Permalink
getting all file content
Browse files Browse the repository at this point in the history
  • Loading branch information
thlorenz committed May 27, 2012
1 parent a6bcb8a commit 421f919
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,29 @@ function isAbsolute(path) {

var target = isAbsolute(dir) ? dir : path.join(__dirname, dir);

function transformAndSave(files) {
function transformAndSave(files, fcb) {
console.log('Adding table of content to %s files.', files.length);

async.forEach(
files,
function (f, cb) {
fs.readFile(f.path, 'utf8', function (err, content) {
if (err) { console.log(err); cb(); return; }
transform(f, content, cb);
});
},
fcb);
}

function transform (f, content, cb) {
console.log('transforming', f);
console.log(content);
cb();
}

file.findMarkdownFiles(target, transformAndSave);


file.findMarkdownFiles(target, function (files) {
transformAndSave(files, function () { console.log('Everything is OK'); });
});

0 comments on commit 421f919

Please sign in to comment.