From 56e70791ac42156218dc6e6eaa68135f5ba9a339 Mon Sep 17 00:00:00 2001 From: Shane Tomlinson Date: Tue, 21 Jun 2016 16:53:27 +0100 Subject: [PATCH] feat(middleware): Call `next` for files that match the exclude path. Allow different/additional processing on files that are on the exclude list. --- index.js | 6 +----- test/middleware.js | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index a24b35b..4790abc 100644 --- a/index.js +++ b/index.js @@ -77,11 +77,7 @@ module.exports = function(options) { if (micromatch.any(req.path.replace(/^\/+|\/+$/g, ''), exclude)) { log('Excluded: %s (%s)', req.path, exclude); res.append('X-Babel-Cache', false); - res.sendFile(src, {}, function(err) { - if (err) { - handleError(res, err); - } - }); + next(); return; } } diff --git a/test/middleware.js b/test/middleware.js index a35250b..13b1848 100644 --- a/test/middleware.js +++ b/test/middleware.js @@ -249,12 +249,14 @@ describe('middleware', function() { describe('excluding files', function() { beforeEach(function() { + var root = __dirname + '/fixtures'; this.app = express(); this.app.use(babelMiddleware({ cachePath: 'memory', - srcPath: __dirname + '/fixtures', + srcPath: root, exclude: ['*syntax*'] })); + this.app.use(express.static(root)); }); it('returns the original file on request', function(done) {