XObject = imports.XObject.XObject;
File = imports.File.File;
-TextStream = imports.TextStream.TextStream;
+TextStream = imports.JSDOC.TextStream.TextStream ;
TokenReader = imports.TokenReader.TokenReader;
ScopeParser = imports.ScopeParser.ScopeParser;
TokenStream = imports.TokenStream.TokenStream;
Collapse = imports.Collapse.Collapse;
GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
/**
* @namespace JSDOC
* @class Packer
files : [ "/location/of/file1.js", "/location/of/file2.js", ... ],
target : "/tmp/output.js",
debugTarget : "/tmp/output.debug.js", // merged file without compression.
+ debugTranslateTarget : "/tmp/output.translate.js", // merged with translation
+ // and no compression
translateJSON: "/tmp/translate.json",
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) {
- print(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 = {
*/
module: false,
/**
- * @cfg {String} debugTargettarget to write files debug version to (uncompacted)- must be full path.
+ * @cfg {String} debugTarget target to write files debug version to (uncompacted)- must be full path.
*/
debugTarget : '', // merged file without compression.
+ /**
+ * @cfg {String} debugTranslateTarget target to write files debug version
+ * to (uncompacted) but with translation- must be full path.
+ */
+
+ debugTranslateTarget
+
/**
* @cfg {String} tmpDir (optional) where to put the temporary files.
* if you set this, then files will not be cleaned up
* 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
continue;
}
+ // debug Target
+
if (this.debugTarget) {
File.append(this.debugTarget, File.read(file));
}
print("compare : " + mt + "=>" + ot);
if (mt >= ot) {
continue;
- /*
- // then the min'files time is > than original..
- var str = File.read(minfile);
- print("using MIN FILE "+ minfile);
- if (str.length) {
- File.append(outpath, str + "\n");
- }
- continue;
- */
}
}
}
}
+ print("Output file: " + this.target);
+ if (this.debugTarget) print("Output debug file: " + this.debugTarget);
keepWhite : true,
keepComments : true,
sepIdents : true,
- collapseWhite : false
+ collapseWhite : false,
+ filename : fn
});
this.timerPrint("START" + fn);
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;