JSDOC/Packer.js
authoralan <alan@alanfast.akbkhome.com>
Wed, 21 Apr 2010 06:16:04 +0000 (14:16 +0800)
committeralan <alan@alanfast.akbkhome.com>
Wed, 21 Apr 2010 06:16:04 +0000 (14:16 +0800)
JSDOC/Packer.js

index bcd1bc0..fc9acb8 100644 (file)
@@ -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);