Skip to content

Commit

Permalink
Extract lastmodified from handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
cweider committed Feb 20, 2012
1 parent 2797c2f commit d6d4178
Showing 1 changed file with 45 additions and 37 deletions.
82 changes: 45 additions & 37 deletions node/utils/Minify.js
Expand Up @@ -78,43 +78,11 @@ function _handle(req, res, jsFilename, jsFiles) {


async.series([ async.series([
//find out the highest modification date //find out the highest modification date
function(callback) function (callback) {
{ lastModifiedDate(function (date) {
var folders2check = [CSS_DIR, JS_DIR]; latestModification = date;

callback()
//go trough this two folders });
async.forEach(folders2check, function(path, callback)
{
//read the files in the folder
fs.readdir(path, function(err, files)
{
if(ERR(err, callback)) return;

//we wanna check the directory itself for changes too
files.push(".");

//go trough all files in this folder
async.forEach(files, function(filename, callback)
{
//get the stat data of this file
fs.stat(path + "/" + filename, function(err, stats)
{
if(ERR(err, callback)) return;

//get the modification time
var modificationTime = stats.mtime.getTime();

//compare the modification time to the highest found
if(modificationTime > latestModification)
{
latestModification = modificationTime;
}

callback();
});
}, callback);
});
}, callback);
}, },
function(callback) function(callback)
{ {
Expand Down Expand Up @@ -280,6 +248,46 @@ function getAceFile(callback) {
}); });
} }


function lastModifiedDate(callback) {
var folders2check = [CSS_DIR, JS_DIR];
var latestModification = 0;
//go trough this two folders
async.forEach(folders2check, function(path, callback)
{
//read the files in the folder
fs.readdir(path, function(err, files)
{
if(ERR(err, callback)) return;

//we wanna check the directory itself for changes too
files.push(".");

//go trough all files in this folder
async.forEach(files, function(filename, callback)
{
//get the stat data of this file
fs.stat(path + "/" + filename, function(err, stats)
{
if(ERR(err, callback)) return;

//get the modification time
var modificationTime = stats.mtime.getTime();

//compare the modification time to the highest found
if(modificationTime > latestModification)
{
latestModification = modificationTime;
}

callback();
});
}, callback);
});
}, function () {
callback(latestModification);
});
}

exports.requireDefinition = requireDefinition; exports.requireDefinition = requireDefinition;
function requireDefinition() { function requireDefinition() {
return 'var require = ' + RequireKernel.kernelSource + ';\n'; return 'var require = ' + RequireKernel.kernelSource + ';\n';
Expand Down

0 comments on commit d6d4178

Please sign in to comment.