-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handling errors properly #62
base: master
Are you sure you want to change the base?
handling errors properly #62
Conversation
if (!/\.(pug|jade)/.test(path.extname(file))) { | ||
return | ||
} | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only wrap the actual pug calls, not the whole logic block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that was my initial approach too.
Buuut, the nice thing about throw
is that it "breaks" forEach
like break
does with a classic loop.
Hence I decided to wrap the whole block.
Otherwise we would need to accumulate errors in an array...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I prefer to bail-out on first error, but I can quickly change it to try all files.
files[name] = data | ||
}) | ||
|
||
setImmediate(done) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can just call done()
instead of using setImmediate
given the new direction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, setImmediate
let's other i/o operations taking place before calling the next metalsmith plugin. see: https://nodejs.org/api/timers.html#timers_setimmediate_callback_args
need to add a test as well. |
here you go, a simple test to check if |
@ahmadnassri |
fixes #61