X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=tools%2Fjsmin.js;h=95c275b621d1241b2913487b9d84b1533a5f08c8;hp=55ee6548e6e2239fe0616afb8cc04a9d6e29d450;hb=82aea119013e63c3d4864baea690c84f56890008;hpb=6d3135b870db381965b197af7d282a99f52e43d8 diff --git a/tools/jsmin.js b/tools/jsmin.js index 55ee654..95c275b 100644 --- a/tools/jsmin.js +++ b/tools/jsmin.js @@ -1,3 +1,5 @@ +#!/usr/bin/env rhino + /* jsmin.js - 2006-08-31 Author: Franck Marcia This work is an adaptation of jsminc.c published by Douglas Crockford. @@ -324,16 +326,17 @@ function jsmin(comment, input, level) { return comment + ret; } - -(function (a) { - if (!a[0]) { - print("Usage: jsmin.js file.js"); - quit(1); - } - var input = readFile(a[0]); - if (!input) { - print("jslint: Couldn't open file '" + a[0] + "'."); - quit(1); - } - print(jsmin(input)); + +importPackage(java.io); +(function (a) { + // in is a reserved javascript word, so we need to use [] for access + var readingIn = new BufferedReader(new InputStreamReader(java.lang.System["in"])); + var sInput = ""; + var str = ""; + while(str != null) { + sInput += str + '\n'; + + str = readingIn.readLine(); + } + print(jsmin(sInput)); })(arguments); \ No newline at end of file