Code coverage report for browserify-middleware/lib/directory.js

Statements: 100% (14 / 14)      Branches: 100% (6 / 6)      Functions: 100% (3 / 3)      Lines: 100% (13 / 13)      Ignored: none     

All files » browserify-middleware/lib/ » directory.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191 1 1 1   1 1 2 2 48 36 36 24     12      
var join = require('path').join;
var fs = require('fs');
var send = require('./send');
var normalize = require('./settings').normalize;
 
module.exports = directory;
function directory(path, options) {
  options = normalize(options);
  return function (req, res, next) {
    if (options.grep.test(req.path)) {
      fs.stat(join(path, req.path), function (err, stat) {
        if (err || !stat.isFile()) return next();
        send(join(path, req.path), options, req, res, next);
      });
    } else {
      return next();
    }
  };
}