Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions lib/plugins/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

var fs = require('fs')
, basename = require('path').basename
, extname = require('path').extname;
, extname = require('path').extname
, dirname = require('path').dirname;

/**
* Restart the server the given js `files` have changed.
Expand Down Expand Up @@ -89,9 +90,31 @@ exports = module.exports = function(files, options){
if (stat.isDirectory()) {
if (~exports.ignoreDirectories.indexOf(basename(file))) return;
fs.readdir(file, function(err, files){
files.map(function(f){
return file + '/' + f;
}).forEach(traverse);
if (!err) {
files.map(function(f){
return file + '/' + f;
}).forEach(traverse);
} else {
if (err.errno === 2) {
fs.readlink(file, function(err, resolvedLink) {
if (!err) {
fs.readdir(dirname(file) + '/' + resolvedLink, function(err, files){
if(!err) {
files.map(function(f){
return file + '/' + f;
}).forEach(traverse);
} else {
console.error('Error reading directory ' + dirname(file) + '/' + resolvedLink, err.message);
}
});
} else {
console.log('error reading directory ' + file, err.message);
}
});
} else {
console.log('error reading directory ' + file, err.message);
}
}
});
} else {
watch(file);
Expand All @@ -115,7 +138,7 @@ exports = module.exports = function(files, options){
master.on('restarting', function(){
restarting = true;
});
}
};
};

/**
Expand Down