Skip to content

Commit

Permalink
Factor out taring process.
Browse files Browse the repository at this point in the history
  • Loading branch information
cweider committed Jan 22, 2012
1 parent 9e16b9a commit ab02135
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions node/utils/Minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit ab02135

Please sign in to comment.