From 375db97a0aaa7103cfa3fd5794a274ad84524474 Mon Sep 17 00:00:00 2001 From: alan Date: Wed, 21 Apr 2010 14:16:04 +0800 Subject: [PATCH] JSDOC/Packer.js --- JSDOC/Packer.js | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/JSDOC/Packer.js b/JSDOC/Packer.js index bcd1bc0..fc9acb8 100644 --- a/JSDOC/Packer.js +++ b/JSDOC/Packer.js @@ -72,15 +72,14 @@ Packer = function(cfg) if (!this.files) { throw "No Files"; } - if (!this.target) { - throw "No Target"; - } + if ((this.tmpDir != Packer.prototype.tmpDir) && (!cfg.cleanup)) { this.cleanup = false; // do not clean up files.. = as tmpdir is set. } this.timer = new Date() * 1; this.packAll(); + } Packer.prototype = { @@ -110,12 +109,18 @@ Packer.prototype = { */ cleanup : true, // + + out : '', // if no target is specified - then this will contain the result + packAll : function() // do the packing (run from constructor) { //this.transOrigFile= bpath + '/../lang.en.js'; // needs better naming... //File.write(this.transfile, ""); - File.write(this.target, ""); + if (this.target) { + File.write(this.target, ""); + } + if (this.debugTarget) { File.write(this.debugTarget, ""); } @@ -183,7 +188,13 @@ Packer.prototype = { print("MERGING LANGUAGE"); - File.write(this.target, "if (typeof(_T) == 'undefined') { _T={};}\n"); + var out = "if (typeof(_T) == 'undefined') { _T={};}\n" + if (this.target) { + File.write(this.target, out); + } else { + this.out += out; + } + File.write(this.translateJSON, ""); @@ -194,7 +205,12 @@ Packer.prototype = { if (File.exists(transmd5)) { var str = File.read(transmd5); if (str.length) { - File.append(this.target, str + "\n"); + if (this.target) { + File.append(this.target, str + "\n"); + } else { + this.out += str + "\n"; + } + } if (this.cleanup) { File.remove(transmd5); @@ -227,7 +243,12 @@ Packer.prototype = { var str = File.read(minfile); print("using MIN FILE "+ minfile); if (str.length) { - File.append(this.target, str + "\n"); + if (this.target) { + File.append(this.target, str + "\n"); + } else { + this.out += str + "\n"; + } + } if (this.cleanup) { File.remove(minfile); -- 2.39.2