Skip to content

Commit

Permalink
Add warning about using Handlebars < 4.0.
Browse files Browse the repository at this point in the history
Warning will disappear when express-handlebars update bumping handlebars dependency is released, provided that the new express-handlebars isn't a major version bump (since our dep is ^2.0.0)
  • Loading branch information
sgress454 committed Jan 6, 2016
1 parent b1e765d commit ff56838
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/hooks/views/layoutshim.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

var path = require('path');

var semver = require('semver');

/**
* Implement EJS layouts (a la Express 2)
Expand Down Expand Up @@ -44,6 +44,21 @@ module.exports = function layoutshim (sails, cb) {

else if (engineName === 'handlebars') {
var exphbs = require('express-handlebars');
var handlebarsMajorVersion;
try {
handlebarsMajorVersion = semver.major(require('express-handlebars/node_modules/handlebars').VERSION);
} catch (e) {
try {
handlebarsMajorVersion = semver.major(require('handlebars').VERSION);
}
catch (e2) {
handlebarsVersion = null;
}
}
if (!handlebarsMajorVersion) {sails.log.warn('Could not determine Handlebars version; versions < 4.0.0 may introduce security risks (see https://snyk.io/test/npm/handlebars/3)');}
else if (handlebarsMajorVersion < 4) {
sails.log.warn('Using Handlebars v' + handlebarsMajorVersion + '.x; Versions < 4.0.0 may introduce security risks (see https://snyk.io/test/npm/handlebars/3).');
sails.log.warn('When an updated version becomes available, you should be able to install it by updating your copy of Sails with `npm update`.');}
return sails.after('hook:http:loaded', function() {
sails.log.verbose('Overriding handlebars engine with express-handlebars to implement layout support...');
var hbs = exphbs.create({
Expand Down

0 comments on commit ff56838

Please sign in to comment.