A golang port of the awesome jsbeautifier tool
This is a port of the awesome jsbeautifier tool to golang.
Granted this is a very basic and naive attempt since this is one of my first takes with golang.
Implemented most of the original features from jsbeautifier (missing features are listed in the following section).
- Unpacking & Deobfuscation (and with that code eval)
- Reading from stdin
- Finish implementing features to match the current state of JsBeautifier
- Unpacking & Deobfuscation
go get && go run main.go test.js
From within the source folder run:
go test ./...
or use something like goconvey
usage:
jsbeautifier [options] PATH
options:
--indent-size=SIZE Indentation Size [default: 4]
--indent-char=CHAR Indentation Char [default: space]
--brace-style=STYLE Brace Style (expand, collapse, end-exapnd or none) [default: collapse]
--outfile=OUTPUTFILE Output results to a file [default: stdout]
-z --eval-code Eval JS code (dangerous!)
-f --keep-function-indentation Keep original function indentation
-t --indent-with-tabs Use tabs to indent
-d --disable-preserve-newlines Don't preserve newlines
-P --space-in-paren Use spaces in parenthesis
-E --space-in-empty-paren Use spaces in empty parenthesis
-j --jslint-happy Keep JSLint happy :)
-a --space_after_anon_function Use spaces after anonymous functions
-x --unescape-strings Unescape strings
-X --e4x Parse XML by e4x standard
-n --end-with-newline End output with newline
-w --wrap-line-length Wrap line length
-i --stdin Use stdin as input
-h --help Show this screen
--version Show version
You are free to use this in any way you want, in case you find this useful or working for you but you must keep the copyright notice and license. (MIT)
- Einar Lielmanis, [email protected] | Original author of the jsbeautifier tool
- docopt / go-docopt / flynn | For writing, porting and supporting docopt