Skip to content
This repository

View lookup should return something at least #1065

Closed
wants to merge 1 commit into from

2 participants

Gabriel Farrell TJ Holowaychuk
Gabriel Farrell
gsf commented

Even if the path doesn't exist it's better for the lookup
method to return the last path checked. Without a return
value, if one attempts to render a path that doesn't
exist one gets "TypeError: Bad argument" because the
first param for fs.readFile is undefined. If the path is
returned one gets the more helpful "Error: ENOENT, no
such file or directory" along with the string for the
path.

Gabriel Farrell gsf View lookup should return something at least
Even if the path doesn't exist it's better for the lookup
method to return the last path checked. Without a return
value, if one attempts to render a path that doesn't
exist one gets "TypeError: Bad argument" because the
first param for fs.readFile is undefined. If the path is
returned one gets the more helpful "Error: ENOENT, no
such file or directory" along with the string for the
path.
fd5127e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 02, 2012
Gabriel Farrell gsf View lookup should return something at least
Even if the path doesn't exist it's better for the lookup
method to return the last path checked. Without a return
value, if one attempts to render a path that doesn't
exist one gets "TypeError: Bad argument" because the
first param for fs.readFile is undefined. If the path is
returned one gets the more helpful "Error: ENOENT, no
such file or directory" along with the string for the
path.
fd5127e
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 2 deletions. Show diff stats Hide diff stats

  1. +1 2  lib/view.js
3  lib/view.js
@@ -66,8 +66,7 @@ View.prototype.lookup = function(path){
66 66 if (exists(path)) return path;
67 67
68 68 // <path>/index.<engine>
69   - path = join(dirname(path), basename(path, ext), 'index' + ext);
70   - if (exists(path)) return path;
  69 + return join(dirname(path), basename(path, ext), 'index' + ext);
71 70 };
72 71
73 72 /**

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.