 convertOnTheFly = (basePath, ext, conv) ->
   (req, res, next) ->
     return next() unless req.method in ['GET', 'HEAD']
-    filePath = resolve basePath, req.path.slice 1
+    filePath = resolvePath basePath, req.path.slice 1
     return next() unless filePath.endsWith(ext)
     fs.exists filePath, (doesExist) ->
       return next() unless doesExist

minimist = require 'minimist'
fs = require 'fs'
pathJoin = require('path').join
require('mcrio-stdlib').monkey()
resolve = require 'resolve-path'

module.exports = ->
  # CONFIGURATION

  app = express()

  localRootPath = process.cwd()
  localBowerPath = join localRootPath, 'bower_components'

  installationRootPath = resolve __dirname, '..'
  installationBowerPath = join installationRootPath, 'bower_components'

  # **/index.html
  app.use (req, res, next) ->
    path = resolvePath localRootPath, req.path.slice 1
    if path.endsWith '/'
      path = path.slice 0, -1
    indexFilePath = path + '/index.html'
