Skip to content

Commit

Permalink
Add support for asynchronous assertions through logging
Browse files Browse the repository at this point in the history
For full history see 73ee48e.
  • Loading branch information
Avaq committed Jul 4, 2020
1 parent 67bde9e commit c4c44ab
Show file tree
Hide file tree
Showing 9 changed files with 549 additions and 114 deletions.
15 changes: 8 additions & 7 deletions lib/command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ if (program.args.length === 0) {
process.exit (1);
}

Promise.all (program.args.map (function(path) {
return (doctest (path, program)).then (function(results) {
return results.reduce (function(status, tuple) {
return tuple[0] ? status : 1;
}, 0);
program.args.reduce (function(promise, path) {
return promise.then (function(ok) {
return (doctest (path, program)).then (function(results) {
return ok && results.every (function(t) { return t[0]; });
});
});
})).then (function(statuses) {
process.exit (statuses.every (function(s) { return s === 0; }) ? 0 : 1);
}, Promise.resolve (true))
.then (function(ok) {
process.exit (ok ? 0 : 1);
}, function(err) {
process.stderr.write (formatErrors ([err.message]));
process.exit (1);
Expand Down
Loading

0 comments on commit c4c44ab

Please sign in to comment.