|
|
|
@ -30,9 +30,8 @@ public class JavaScriptFormatHelper {
|
|
|
|
|
* @see <a href="https://github.com/beautify-web/js-beautify">JSBeautify<a/> |
|
|
|
|
*/ |
|
|
|
|
public static String beautify(String jsCode, BeautifyOption option) { |
|
|
|
|
InputStream resourceAsStream = IOUtils.readResource("com/fr/design/javascript/beautify/beautify.js"); |
|
|
|
|
String result = jsCode; |
|
|
|
|
try { |
|
|
|
|
try (InputStream resourceAsStream = IOUtils.readResource("com/fr/design/javascript/beautify/beautify.js")) { |
|
|
|
|
ScriptEngine nashorn = new ScriptEngineManager().getEngineByName("JavaScript"); |
|
|
|
|
nashorn.eval(IOUtils.inputStream2String(resourceAsStream, EncodeConstants.ENCODING_UTF_8)); |
|
|
|
|
Invocable invocable = (Invocable) nashorn; |
|
|
|
|