Skip to content

Commit 4007570

Browse files
committed
added cb to module + err context
1 parent 026b55b commit 4007570

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

generate-report.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
output = require('./utils/output')
88
;
99

10-
crawlComplexity(srcDir, function(report){ output(report, outputDir); });
10+
crawlComplexity(srcDir, function(err, report){ if(!err) output(report, outputDir); });
1111

1212

1313

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
module.exports = function(srcDir){ console.log(srcDir);
1+
module.exports = function(srcDir, cb){ console.log(srcDir);
22

33
var crawlComplexity = require('./utils/crawl-complexity');
44

5-
crawlComplexity(srcDir, function(report){ console.log(report) });
5+
crawlComplexity(srcDir, function(err, report){ cb(err, report); });
66

77
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jscomplexity",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"preferGlobal" : "true",
55
"bin": {
66
"jscr": "generate-report.js"

sample.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
var jscr = require('./index');
22

3-
jscr('./utils');
3+
jscr('./utils', function(err, report){
4+
5+
if (!err) console.log(report);
6+
7+
});

utils/crawl-complexity.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
} else { next(); }
4545

4646
})
47-
.on("end", function() { cb(reportList); })
47+
.on("error", function(){ cb(err); })
48+
.on("end", function(){ cb(null, reportList); })
4849
;
4950

5051
}

0 commit comments

Comments
 (0)