Skip to content

Commit 8a41c06

Browse files
committed
perf: resolve file paths at start up
1 parent 7aaf687 commit 8a41c06

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
unreleased
2+
==========
3+
4+
* perf: resolve file paths at start up
5+
16
1.4.3 / 2016-01-17
27
==================
38

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
var accepts = require('accepts')
1818
var escapeHtml = require('escape-html');
1919
var fs = require('fs');
20+
var path = require('path')
2021
var util = require('util')
2122

2223
/**
2324
* Module variables.
2425
* @private
2526
*/
2627

28+
var TEMPLATE_PATH = path.join(__dirname, '/public/error.html')
29+
var STYLESHEET_PATH = path.join(__dirname, '/public/style.css')
2730
var doubleSpaceGlobalRegExp = / /g
2831
var inspect = util.inspect
2932
var newLineGlobalRegExp = /\n/g
@@ -116,9 +119,9 @@ exports = module.exports = function errorHandler(options) {
116119

117120
// html
118121
if (type === 'html') {
119-
fs.readFile(__dirname + '/public/style.css', 'utf8', function(e, style){
122+
fs.readFile(STYLESHEET_PATH, 'utf8', function (e, style) {
120123
if (e) return next(e);
121-
fs.readFile(__dirname + '/public/error.html', 'utf8', function(e, html){
124+
fs.readFile(TEMPLATE_PATH, 'utf8', function (e, html) {
122125
if (e) return next(e);
123126
var isInspect = !err.stack && String(err) === toString.call(err)
124127
var errorHtml = !isInspect

0 commit comments

Comments
 (0)