]> source.dussan.org Git - jquery.git/commitdiff
Builds minimal license header block for jquery.min.js
authorRick Waldron <waldron.rick@gmail.com>
Sat, 23 Jul 2011 21:53:53 +0000 (17:53 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Sat, 23 Jul 2011 21:58:08 +0000 (17:58 -0400)
build/post-compile.js

index 1bbeaa6f4868a93a9236f9ee116e0e98e75b7532..ea93c50ff32fec8b593eed76da8986ee56afa24e 100644 (file)
@@ -1,7 +1,20 @@
 #!/usr/bin/env node
 
-var print = require("sys").print,
-       src = require("fs").readFileSync(process.argv[2], "utf8");
+var print = require( "sys" ).print,
+       fs = require( "fs" ),
+       src = fs.readFileSync( process.argv[2], "utf8" ),
+       version = fs.readFileSync( "version.txt", "utf8" ),
+       // License Template
+       license = "/*! jQuery v@VERSION @DATE http://jquery.com/ | http://jquery.org/license */";
+
+
+license = license.replace( "@VERSION", version )
+                                               .replace( "@DATE", (new Date()).toLocaleString() );
 
 // Previously done in sed but reimplemented here due to portability issues
-print( src.replace( /^(\s*\*\/)(.+)/m, "$1\n$2" ) + ";" );
+src = src.replace( /^(\s*\*\/)(.+)/m, "$1\n$2" ) + ";";
+
+// Replace license block with minimal license
+src = src.replace( /\/\/.*?\/?\*.+?(?=\n|\r|$)|\/\*[\s\S]*?\/\/[\s\S]*?\*\//, license );
+
+print( src );