Skip to content

Commit

Permalink
optionally include source contents in the results
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday authored and defunctzombie committed Feb 11, 2013
1 parent ac9a25a commit 4a16ba0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ Each object in the array takes the following form:
{
// if true, then missing modules will be silently ignored
// useful if you don't care about some failed requires with native builds
ignoreMissing: false;
ignoreMissing: false,
// if true, include the source contents for each file in the results
// in a "source" field
includeSource: false
}
```

Expand Down
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,20 @@ function from_source(source, parent, opt, cb) {
paths: paths
}

from_filename(full_path, new_parent, opt, function(err, deps) {
from_filename(full_path, new_parent, opt, function(err, deps, src) {
if (err) {
return cb(err);
}

result.push({
var res = {
id: id,
filename: full_path,
deps: deps
});
};
if (opt.includeSource) {
res.source = src;
}
result.push(res);

next();
});
Expand Down Expand Up @@ -125,7 +129,7 @@ function from_filename(filename, parent, opt, cb) {

// push onto the result set so circular references are populated
result.push.apply(result, deps);
return cb(err, result);
return cb(err, result, content);
});
} catch (err) {
err.message = filename + ': ' + err.message;
Expand Down

0 comments on commit 4a16ba0

Please sign in to comment.