Would something like this do it?

<code>
var engine = options.settings['view engine'] || 'ejs'
  , desiredExt = '.' + engine
  , ext = extname(file) || desiredExt
  , key = [themeFilePath, file, ext].join('-');
//Check if the file has already been resolved in the theme folder to avoid io
if (options.cache && cache[key]) file = cache[key]; 
if (fs.existsSync(resolve(themeFilePath, basename(file)))) {
	cache[key] = resolve(themeFilePath, basename(file));
	file = resolve(themeFilePath, basename(file));
}</code>