Permalink
Browse files

Added YUI Compressor and -m switch

  • Loading branch information...
chriso committed Dec 19, 2010
1 parent cb80043 commit 6baafac7074881ac70de5831e1a7d0aecf2460f7
Showing with 17 additions and 6 deletions.
  1. +5 −5 README.md
  2. +12 −1 packnode
  3. BIN yui.jar
View
@@ -1,4 +1,4 @@
-`packnode` minifies and encrypts node modules for private use.
+`packnode` runs node modules through JSMin and encrypts them for private use.
To install packnode, use [npm](http://github.com/isaacs/npm)
@@ -41,14 +41,14 @@ CoffeeScript modules can be packed using
$ cat myscript.coffee | coffee -c -s | packnode pass123 > packed.js
+To obfuscate code, use the included YUI Compressor v2.4.2 (requires Java)
+
+ $ java -jar yui.jar myscript.js | packnode pass123 > packed.js
+
To specify a custom encryption algorithm or output encoding, use `-a` and `-e`
$ packnode -a aes256 -e hex < myscript.js > packed.js
-To unpack a packed node, use the `-u` switch
-
- $ packnode -u pass123 < packed.js > unpacked.js
-
[node.io](http://node.io) has built-in support for unpacking private modules.
To run a packed job, use the `-u` switch to specify the password
View
@@ -11,7 +11,7 @@ var cipher, data = '', encrypted, out, chunk = [],
encoding = 'base64',
algorithm = 'aes256',
chunk_length = 100,
- password, unpack;
+ password, unpack, minify;
var exit = function (msg, is_error) {
console.log(msg);
@@ -25,6 +25,7 @@ var usage = ''
+ '\x1b[1mExample 2\x1b[0m: cat input.coffee | coffee -c -s | packnode mypassword > output.js\n'
+ '\n'
+ '\x1b[1mOptions\x1b[0m:\n'
+ + ' -m, --minify Just minify the input using JSMin\n'
+ ' -a, --algorithm <..> Use the specified algorithm. Default is "aes256"\n'
+ ' -e, --encoding <..> Encode with base64|hex|binary. Default is "hex"\n'
+ ' -u, --unpack Unpack the module using the specified password\n'
@@ -50,6 +51,10 @@ while (args.length) {
case '--unpack':
unpack = true;
break;
+ case '-m':
+ case '--minify':
+ minify = true;
+ break;
case '-h':
case '--help':
exit(usage);
@@ -150,6 +155,12 @@ stdin.on('end', function () {
// Minify the file
data = jsmin(data);
+ if (minify) {
+ // Are we just minifying the file?
+ process.stdout.write(data);
+ return;
+ }
+
// Encrypt the file
cipher = crypto.createCipher(algorithm, password);
encrypted = cipher.update(data, 'binary', encoding) + cipher.final(encoding);
View
BIN yui.jar
Binary file not shown.

0 comments on commit 6baafac

Please sign in to comment.