Javascript Beautifier in command-line (and in Geany editor)
source link: https://blog.mathieu-leplatre.info/javascript-beautifier-in-command-line-and-in-geany-editor.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Javascript Beautifier in command-line (and in Geany editor)
Tue 01 February 2011Install a Javascript engine (like Mozilla Rhino)
sudo aptitude install rhino
Get the beautifier script (put it somewhere like ~/.bin)
wget http://jsbeautifier.org/beautify.js
Add the following at the end of beautify.js
print( js_beautify( readFile( arguments[0] )));
Create a shell script that will call it (like ~/.bin/beautifyjs)
#!/bin/sh java -cp /usr/share/java/js.jar org.mozilla.javascript.tools.shell.Main ~/.bin/beautify.js $*
Make sure to set it executable
chmod +x ~/.bin/beautifyjs
Use it from command-line
At least to check that it works !
~/.bin/beautifyjs /your/file.js
Or in Geany Editor
Open a Javascript file
Open menu Build > Define Build Commands
Create a new entry (like beautify)
In command, enter the following
~/.bin/beautifyjs %f > /tmp/tmpfile.js && geany /tmp/tmpfile.jsIn working directory, enter %d
#tips, #javascript - Posted in the Dev category
© Copyright 2020 by Mathieu Leplatre. mnmlist Theme
Content licensed under the Creative Commons attribution-noncommercial-sharealike License.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK