Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,25 @@ function View(name, options) {
* Lookup view by the given `name`
*
* @param {string} name
* @returns {(string|undefined)} The resolved absolute file path if found, otherwise `undefined`.
* @private
*/

View.prototype.lookup = function lookup(name) {
var path;
var roots = [].concat(this.root);
const roots = [].concat(this.root);

debug('lookup "%s"', name);

for (var i = 0; i < roots.length && !path; i++) {
var root = roots[i];
for (const root of roots) {
const loc = resolve(root, name);
const dir = dirname(loc);
const file = basename(loc);

// resolve the path
var loc = resolve(root, name);
var dir = dirname(loc);
var file = basename(loc);

// resolve the file
path = this.resolve(dir, file);
const found = this.resolve(dir, file);
if (found) return found;
}

return path;
return undefined;
};

/**
Expand Down