From 3da1464ae053bb0e098b35b950906e41d6439ce4 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 5 Feb 2012 14:54:20 -0800 Subject: [PATCH] Minify serves the require kernel. --- node/server.js | 5 ----- node/utils/Minify.js | 25 +++++++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/node/server.js b/node/server.js index e6cf99386..aa94c159e 100644 --- a/node/server.js +++ b/node/server.js @@ -143,11 +143,6 @@ async.waterfall([ }); //serve static files - app.get('/static/js/require-kernel.js', function (req, res, next) { - res.header("Content-Type","application/javascript; charset: utf-8"); - res.write(minify.requireDefinition()); - res.end(); - }); var assetCache = new CachingMiddleware; app.all('/static/js/:filename', assetCache.handle, minify.minifyJS); app.get('/static/*', function(req, res) diff --git a/node/utils/Minify.js b/node/utils/Minify.js index 883c327c9..204fd15d7 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -201,7 +201,6 @@ function lastModifiedDate(callback) { }); } -exports.requireDefinition = requireDefinition; function requireDefinition() { return 'var require = ' + RequireKernel.kernelSource + ';\n'; } @@ -226,23 +225,29 @@ function getFileCompressed(filename, callback) { function getFile(filename, callback) { if (filename == 'ace.js') { getAceFile(callback); + } else if (filename == 'require-kernel.js') { + callback(undefined, requireDefinition()); } else { fs.readFile(JS_DIR + filename, "utf8", callback); } } function fileExists(filename, callback) { - fs.stat(JS_DIR + filename, function (error, stats) { - if (error) { - if (error.code == "ENOENT") { - callback(undefined, false); + if (filename == 'require-kernel.js') { + callback(undefined, true); + } else { + fs.stat(JS_DIR + filename, function (error, stats) { + if (error) { + if (error.code == "ENOENT") { + callback(undefined, false); + } else { + callback(error, undefined); + } } else { - callback(error, undefined); + callback(undefined, stats.isFile()); } - } else { - callback(undefined, stats.isFile()); - } - }) + }); + } } function tarCode(jsFiles, write, callback) {