Skip to content

Commit

Permalink
Merge pull request #82 from Financial-Times/use-logger
Browse files Browse the repository at this point in the history
Use next-logger
  • Loading branch information
ironsidevsquincy committed Apr 7, 2015
2 parents 500a6ca + e41ba58 commit 1fbf282
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"es6-promise": "^2.0.1",
"express": "^4.10.5",
"express-errors-handler": "^1.0.0",
"ft-next-handlebars": "^1.0.1",
"ft-next-logger": "^1.0.0",
"isomorphic-fetch": "^2.0.0",
"next-feature-flags-client": "https://github.com/Financial-Times/next-feature-flags-client/archive/v5.1.1.tar.gz",
"next-barrier-component": "Financial-Times/next-barrier-component#v1",
"ft-next-handlebars": "^1.0.1",
"next-feature-flags-client": "https://github.com/Financial-Times/next-feature-flags-client/archive/v5.1.1.tar.gz",
"next-metrics": "^1.6.1"
},
"devDependencies": {
Expand Down
8 changes: 5 additions & 3 deletions src/handlebars/hashed-asset.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
/*jshint node:true*/
'use strict';

var logger = require('ft-next-logger');

module.exports = function(options) {
var assetHash;
var file = options.fn(this);
var fallback = '/' + options.data.root.__name+'/' + file;
var prefix = (options.data.root.flags.s3.isSwitchedOn ? '' : 'next-') + 'hashed-assets';
if (process.env.NODE_ENV !== 'production') {
console.log("Asset hashing is only switched on when NODE_ENV is production");
logger.info("Asset hashing is only switched on when NODE_ENV is production");
return fallback;
}

if (!options.data.root.flags.assetHashing.isSwitchedOn) {
console.warn("Asset Hashing flag off, falling back to un-fingerprinted files");
logger.warn("Asset Hashing flag off, falling back to un-fingerprinted files");
return fallback;
}

try {
assetHash = require(options.data.root.__rootDirectory + '/public/asset-hashes.json')[file];
} catch(err) {
console.warn("./public/asset-hashes.json not found. Falling back to un-fingerprinted files.");
logger.warn("./public/asset-hashes.json not found. Falling back to un-fingerprinted files.");
}
if (assetHash) {
return '/' + prefix + '/' + options.data.root.__name + '/' + assetHash;
Expand Down

0 comments on commit 1fbf282

Please sign in to comment.