Factor out taring process.

pull/343/head
Chad Weider 2012-01-16 23:26:30 -08:00
parent 9e16b9a575
commit ab02135643
1 changed files with 11 additions and 13 deletions

View File

@ -208,14 +208,9 @@ function _handle(req, res, jsFilename, jsFiles) {
//put all together and write it into a file
function(callback)
{
//put all javascript files in an array
var values = [];
for(var i in jsFiles)
{
values.push(fileValues[jsFiles[i]]);
}
//minify all javascript files to one
var values = [];
tarCode(jsFiles, fileValues, function (content) {values.push(content)});
var result = compressJS(values);
async.parallel([
@ -291,18 +286,21 @@ function _handle(req, res, jsFilename, jsFiles) {
{
if(ERR(err)) return;
for(var i=0;i<jsFiles.length;i++)
{
var fileName = jsFiles[i];
res.write("\n\n\n/*** File: static/js/" + fileName + " ***/\n\n\n");
res.write(fileValues[fileName]);
}
tarCode(jsFiles, fileValues, function (content) {res.write(content)});
res.end();
});
}
}
function tarCode(filesInOrder, files, write) {
for(var i = 0, ii = filesInOrder.length; i < filesInOrder.length; i++) {
var filename = filesInOrder[i];
write("\n\n\n/*** File: static/js/" + filename + " ***/\n\n\n");
write(files[filename]);
}
}
function compressJS(values)
{
var complete = values.join("\n");