From 18008444368b40b30e8c0e55586b7c444948982a Mon Sep 17 00:00:00 2001 From: Vladimir Dronnikov Date: Wed, 14 Jul 2010 21:25:23 +0400 Subject: [PATCH] silence error due to importing standard node modules --- lib/jsgi/transporter.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/jsgi/transporter.js b/lib/jsgi/transporter.js index dee56e4..c012a00 100644 --- a/lib/jsgi/transporter.js +++ b/lib/jsgi/transporter.js @@ -20,15 +20,15 @@ exports.Transporter = function(options, app) { }, autoRun = "autoRun" in options ? options.autoRun : true, excluded = {}; - converter = options.converter || exports.CommonJS; - + converter = options.converter || exports.CommonJS; + excludeModules.forEach(function(moduleId){ excluded[moduleId] = true; }); return function(request) { var modules, isPaused, path = request.pathInfo; if(path.indexOf(prefix) != 0){ - if(app){ + if(app){ return app(request); } return { @@ -115,13 +115,14 @@ exports.Transporter = function(options, app) { return; } if(!fileContents && write){ - errors.push('console.warn(' + JSON.stringify(moduleName) + ' + " not found");\n'); + if (console.warn === undefined) + errors.push('console.warn(' + JSON.stringify(moduleName) + ' + " not found");\n'); return; } if(moduleName === "require"){ - // require.js loads the require handler, which can't be embedded in + // require.js loads the require handler, which can't be embedded in // require.def because require doesn't exist yet - // also hand-coded modules that define their require.def's don't need wrapping/resolution, + // also hand-coded modules that define their require.def's don't need wrapping/resolution, // they can be directly written var baseUrl = request.pathInfo.substring(0, request.pathInfo.lastIndexOf("/") + 1); // we set the base url in the require config so that it knows where to load from @@ -130,10 +131,10 @@ exports.Transporter = function(options, app) { return true; } if(excluded[moduleName] || fileContents.indexOf("require.def(") > -1){ - // also hand-coded modules that define their require.def's don't need wrapping/resolution, + // also hand-coded modules that define their require.def's don't need wrapping/resolution, // they can be directly written write(fileContents); - return true; + return true; } converter(moduleName, fileContents, resolveDeps ? loadModule : function(){ return true;}, modules, write); modules[moduleName] = 2; // finished @@ -300,4 +301,4 @@ exports.DojoRequireJS = function(moduleName, fileContents, loadModule, modules, write(fileContents); write('\n});\n'); } -}; \ No newline at end of file +};