Merge branch 'live' of http://git.roojs.org/gnome.introspection-doc-generator into...
[gnome.introspection-doc-generator] / JSDOC / Packer.js
index d4bb80f..61092ed 100644 (file)
@@ -10,6 +10,7 @@ CompressWhite   = imports.CompressWhite.CompressWhite;
 Collapse        = imports.Collapse.Collapse;
 
 GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
 /**
  * @namespace JSDOC
  * @class  Packer
@@ -83,29 +84,45 @@ Packer = function(cfg)
         throw "No Files";
     }
     
+    var link = false;
     if (cfg.autoBuild) {
+        
+        function dateString(d){
+            function pad(n){return n<10 ? '0'+n : n}
+            return d.getFullYear() +
+                 pad(d.getMonth()+1)+
+                 pad(d.getDate())+'_'+
+                 pad(d.getHours())+
+                 pad(d.getMinutes())+
+                 pad(d.getSeconds());
+        }
+
+        
+        
         var version = 0;
         this.files.forEach(function(f) {
             version = Math.max(File.mtime(f), version);
         });
+        var version  = dateString(new Date(version));
+        
         var dirname = GLib.path_get_dirname(this.files[0]);
         var outname = this.module ? this.module : GLib.path_get_basename(dirname);
         this.target = dirname + '/compiled/' + outname + '-' + version + '.js';
-        if (File.exists(this.target)) {
-            print("Target file already exists");
+         if (File.exists(this.target)) {
+            print("Target file already exists: " + this.target);
             Seed.quit();
         }
         this.prefix = dirname +'/';
         this.translateJSON  = dirname + '/compiled/_translation_.js';
         
     }
-    
-    print(this);
-    Seed.quit();
-    
+     
+    print(this.translateJSON);
     this.timer =  new Date() * 1;
     this.packAll();
     
+    
+    
  
 }
 Packer.prototype = {
@@ -148,6 +165,12 @@ Packer.prototype = {
      *    Defaults to false if you set tmpDir, otherwise true.
      */
     cleanup : true,  
+    /**
+     * @cfg {Boolean} keepWhite (optional) do not remove white space in output.
+     *    usefull for debugging compressed files.
+     */
+    
+    keepWhite: true,
     
     /**
      * @cfg {String} prefix (optional) prefix of directory to be stripped of when
@@ -330,6 +353,8 @@ Packer.prototype = {
             }
             
         }
+        print("Output file: " + this.target);
+        if (this.debugTarget) print("Output debug file: " + this.debugTarget);
         
          
     
@@ -352,7 +377,8 @@ Packer.prototype = {
             keepWhite : true,  
             keepComments : true, 
             sepIdents : true,
-            collapseWhite : false
+            collapseWhite : false,
+            filename : fn
         });
         this.timerPrint("START" + fn);
         
@@ -386,8 +412,9 @@ Packer.prototype = {
         print(sp.warnings.join("\n"));
         
         
-        //var out = CompressWhite(new TokenStream(toks), this, true); // do not kill whitespace..
-        var out = CompressWhite(new TokenStream(toks), this, false);
+        var out = CompressWhite(new TokenStream(toks), this, this.keepWhite); // do not kill whitespace..
+        
+        
         this.timerPrint("Compressed");
         return out;