How to use the jsbeautifier.beautify_file function in jsbeautifier

To help you get started, we’ve selected a few jsbeautifier examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Lopseg / Jsdir / db / parser.py View on Github external
import jsbeautifier
import sys
import os
import random

filename = sys.argv[2]+"-"+str(os.times()[4])+"-"+str(random.randint(1,99999))+".txt"
os.system("copy NUL db/"+filename)

parser = open(sys.argv[1],"r")

body = parser.read().split('\r\n\r\n')
with open("db/"+filename,'w') as f:
    f.write(body[1])
parser.close()

res = jsbeautifier.beautify_file("db/"+filename)
with open("db/"+filename,'w') as f:
    f.write(res)

print filename
github AnyChart / AnyChart / build.py View on Github external
def build_theme(theme, output):
    min_file_name = os.path.join(output, theme + '.min.js')
    file_name = os.path.join(output, theme + '.js')
    (err, output) = __compile(__get_theme_entry_point(theme), min_file_name, flag_file=CHECKS_FLAGS)
    if len(output) > 0:
        print output
    try:
        import jsbeautifier
        res = jsbeautifier.beautify_file(min_file_name)
        with open(file_name, 'w') as f:
            f.write(res)
    except ImportError:
        raise ImportError('Please install jsbeautifier manually first.')
github kirang89 / cleanify / cleanify.py View on Github external
def clean_js(self, jsfile):
        try:
            res = jsbeautifier.beautify_file(jsfile)
            if res:
                fileWriter = open(jsfile, 'w')
                fileWriter.write(res)
                fileWriter.close()
            print "Cleaned", jsfile
        except Exception, e:
            print e
github Shu-Ji / wechat_micro_jump_game_hero / js_beautifier.py View on Github external
# coding: u8

import jsbeautifier


opts = jsbeautifier.default_options()
opts.indent_size = 2
opts.break_chained_methods = True
opts.comma_first = True

min_js_file_path = '../wx7c8d593b2c3a7703_3.wxapkg.unpack/game.js'
res = jsbeautifier.beautify_file(min_js_file_path)

open('./game.beautified2.js', 'w').write(res)