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
Throw if templating a file fails #3786
Throw if templating a file fails #3786
Conversation
I'm going through the upgrade steps for my test-recorder then will link to this branch from my npm and run ember init again. |
return content.toString(); | ||
} | ||
return lstat(path).then(function(fileStat) { | ||
if (isBinaryFile(content, fileStat.size)) { |
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.
we should ad a test for binary files
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.
There already is one, see https://github.com/ember-cli/ember-cli/blob/master/tests/unit/models/file-info-test.js#L69
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.
👍
needs rebase |
Previously, if an error was thrown during the template rendering process, the error was simply swallowed. This was likely to avoid errors when attempting to template a binary file, since the byte stream, when converted to a string, could contain template markers. Adds the isbinaryfile package to detect if the file is binary. If so, it skips templating entirely. If not, it attempts to template the file, and allows exceptions to reject the render promise. This happened to expose some tests that should have been failing around the http-proxy generators (the tests were not supplying enough arguments). Fixes those tests too.
e5e374b
to
7a6173b
Compare
Rebased and addressed all the outstanding comments @stefanpenner |
kicking appveyor |
Throw if templating a file fails
Previously, if an error was thrown during the template rendering process, the error was simply swallowed. This was likely to avoid errors when attempting to template a binary file, since the byte stream, when converted to a string, could contain template markers.
Adds the isbinaryfile package to detect if the file is binary. If so, it skips templating entirely. If not, it attempts to template the file, and allows exceptions to reject the render promise.
This happened to expose some tests that should have been failing around the http-proxy generators (the tests were not supplying enough arguments). Fixes those tests too.