[Pkg-javascript-commits] [sockjs-client] 09/434: Generate prettified javascript, useful for development.
Tonnerre Lombard
tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:46:57 UTC 2014
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch master
in repository sockjs-client.
commit e83490cdd827d3470932fa58c6200db9a402721d
Author: Marek Majkowski <majek04 at gmail.com>
Date: Sat Jul 23 21:47:18 2011 +0100
Generate prettified javascript, useful for development.
---
.gitignore | 1 +
bin/minify.js | 21 +++++++++++++++------
package.json | 3 ++-
run.sh | 3 ++-
4 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index b69fb46..30c72ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
.pidfile.pid
node_modules
sockjs.min.js
+sockjs.pretty.js
sockjs.js
tests/*.js
diff --git a/bin/minify.js b/bin/minify.js
index 8e49565..c18c8e2 100644
--- a/bin/minify.js
+++ b/bin/minify.js
@@ -1,13 +1,22 @@
var fs = require('fs');
var uglify = require('uglify-js');
+var optparse = require('optparse');
+
+var switches = [
+ ['-p', '--pretty', 'Prettify javascript']
+];
(function(){
+ var gen_options = {};
+ var parser = new optparse.OptionParser(switches);
+ parser.on('pretty', function() {
+ gen_options.beautify = true;
+ });
+ var filenames = parser.parse(process.ARGV.slice(2));
+
var content = [];
- var filenames = [];
- for(var i = 2; i < process.argv.length; i++) {
- var filename = process.argv[i];
- filenames.push(filename);
- var data = fs.readFileSync(filename, encoding='utf8');
+ for(var i = 0; i < filenames.length; i++) {
+ var data = fs.readFileSync(filenames[i], encoding='utf8');
content.push( data );
}
console.warn(" [.] Minifying:", filenames.join(', '));
@@ -16,7 +25,7 @@ var uglify = require('uglify-js');
var ast = uglify.parser.parse(data);
ast = uglify.uglify.ast_mangle(ast);
ast = uglify.uglify.ast_squeeze(ast);
- var minified = uglify.uglify.gen_code(ast);
+ var minified = uglify.uglify.gen_code(ast, gen_options);
process.stdout.write(minified);
})();
diff --git a/package.json b/package.json
index f2262a1..cbfb875 100644
--- a/package.json
+++ b/package.json
@@ -3,6 +3,7 @@
"version": "0.0.1",
"dependencies": {
"uglify-js": "1.0.6",
- "coffee-script": "1.1.1"
+ "coffee-script": "1.1.1",
+ "optparse": "1.0.1"
}
}
diff --git a/run.sh b/run.sh
index 34312c3..6690e0e 100755
--- a/run.sh
+++ b/run.sh
@@ -8,8 +8,9 @@ while [ 1 ]; do
echo " [*] Generating javascript"
node bin/render.js lib/main.js > sockjs.js && \
coffee -o tests/ -c --bare tests-src/*.coffee && \
+ node bin/minify.js sockjs.js > sockjs.min.js && \
+ node bin/minify.js --pretty sockjs.js > sockjs.pretty.js && \
while [ 1 ]; do
- node bin/minify.js sockjs.js > sockjs.min.js
echo " [*] Running http server"
node bin/simple_http_server.js &
SRVPID=$!
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list