Skip to content

Commit

Permalink
add try/catch to read helper (#83)
Browse files Browse the repository at this point in the history
* add try/catch to read helper

* rm extra line

* use clay-log
  • Loading branch information
KerenLerner authored Jul 15, 2022
1 parent b91c0a7 commit 6a8283a
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 23 deletions.
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
const glob = require('glob'),
path = require('path'),
outdent = require('outdent'),
fs = require('fs');
fs = require('fs'),
clayLog = require('clay-log'),
log = clayLog.init({
name: 'clayhandlebars'
});

// filter out tests from globbed files
function noTests(filename) {
Expand All @@ -24,7 +28,11 @@ module.exports = function (env) {
// support `read` helper on the server-side ONLY
// todo: deprecate this when we figure out how to precompile these assets
env.registerHelper('read', function (filename) {
return fs.readFileSync(filename, 'utf-8');
try {
return fs.readFileSync(filename, 'utf-8');
} catch (error) {
log('error', `Failure to read ${filename}.`, { error });
}
});

// add helpers
Expand Down
141 changes: 120 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"webpack": "^2.2.1"
},
"dependencies": {
"clay-log": "^1.5.3",
"comma-it": "0.0.7",
"date-fns": "^1.30.1",
"glob": "^7.1.6",
Expand Down

0 comments on commit 6a8283a

Please sign in to comment.