Skip to content

Commit

Permalink
Added monitorModules option
Browse files Browse the repository at this point in the history
Fixed path references when already in file url form
  • Loading branch information
kriszyp committed Oct 14, 2010
1 parent 6460bde commit 0f6287d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/nodules.js
Expand Up @@ -25,6 +25,7 @@ var modules = {},
overlays = {},
callbacks = [],
useSetInterval = false,
monitorModules = true,
packages = {},
filePathMappings = [],
defaultPath = "",
Expand Down Expand Up @@ -169,6 +170,7 @@ try{
if(filePathMappingsJson){
var filePathMappingsObject = JSON.parse(filePathMappingsJson);
useSetInterval = filePathMappingsObject.useSetInterval;
monitorModules = filePathMappingsObject.monitorModules !== false;
for(var i in filePathMappingsObject){
filePathMappings.push({
from: RegExp(i),
Expand Down Expand Up @@ -752,7 +754,7 @@ var watchedFiles;
function readModuleFile(path, uri){
try{
var source = fs.read(path);
if(!watching[path] && !dontWatch[uri]){
if(monitorModules && !watching[path] && !dontWatch[uri]){
watching[path] = true;
if(fs.watchFile && !useSetInterval){
fs.watchFile(path, {persistent: false, interval: process.platform == "darwin" ? 300 : 0}, possibleChange);
Expand Down Expand Up @@ -817,7 +819,7 @@ function cachePath(uri){
filePathMappings.forEach(function(pathMapping){
path = path.replace(pathMapping.from, pathMapping.to);
});
return ((path.charAt(0) == '/' || path.charAt(1) == ':') ? '' : exports.baseFilePath + '/') + path.replace(/^\w*:(\w*:)?\/\//,'').replace(/!\/?/g,'/'); // remove protocol and replace colons and add base file path
return ((path.charAt(0) == '/' || path.charAt(1) == ':' || path.substring(0,5) == "file:") ? '' : exports.baseFilePath + '/') + path.replace(/^\w*:(\w*:)?\/\//,'').replace(/!\/?/g,'/'); // remove protocol and replace colons and add base file path
}
function cache(handler, writeBack){
return function(uri){
Expand Down

0 comments on commit 0f6287d

Please sign in to comment.