mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Better error handling
This commit is contained in:
parent
f3745fd87d
commit
7c0c204bf0
@ -127,18 +127,24 @@ function walk(files, options, done) {
|
||||
|
||||
var fileCallback = options.file;
|
||||
var context = {
|
||||
errors: [],
|
||||
beginAsync: function() {
|
||||
pending++;
|
||||
},
|
||||
endAsync: function(err) {
|
||||
pending--;
|
||||
|
||||
if (err) {
|
||||
return done(err);
|
||||
this.errors.push(err);
|
||||
}
|
||||
|
||||
pending--;
|
||||
|
||||
if (pending === 0) {
|
||||
done(null);
|
||||
if (this.errors.length) {
|
||||
done(this.errors);
|
||||
} else {
|
||||
done(null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -226,6 +232,7 @@ if (args.clean) {
|
||||
} else {
|
||||
var found = {};
|
||||
var compileCount = 0;
|
||||
var failed
|
||||
var failed = [];
|
||||
|
||||
var compile = function(path, context) {
|
||||
@ -276,6 +283,16 @@ if (args.clean) {
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
if (err) {
|
||||
if (failed.length) {
|
||||
console.error('The following errors occurred:\n- ' + failed.join('\n- '));
|
||||
} else {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (compileCount === 0) {
|
||||
console.log('No templates found');
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user