From 857756f63600395c8edce723fa12182a17df47d7 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 1 Nov 2013 11:36:05 -0400 Subject: [PATCH] silly closures... --- src/webserver.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/webserver.js b/src/webserver.js index 605b0e22fe..66dc5e1af6 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -223,13 +223,16 @@ var express = require('express'), async.each(themes, function(themeObj, next) { if (themeObj.screenshot) { screenshotPath = path.join(__dirname, '../node_modules', themeObj.id, themeObj.screenshot); - fs.exists(screenshotPath, function(exists) { - if (exists) { - app.get('/css/previews/' + themeObj.id, function(req, res) { - res.sendfile(screenshotPath); - }); - } - }); + (function(id, path) { + fs.exists(path, function(exists) { + if (exists) { + console.log('routing', id, path); + app.get('/css/previews/' + id, function(req, res) { + res.sendfile(path); + }); + } + }); + })(themeObj.id, screenshotPath); } else { next(false); }