mirror of https://github.com/amol-/dukpy.git
Manually decode JS source code
This commit is contained in:
parent
d769651e24
commit
58b2eb5de7
|
@ -9,9 +9,9 @@ def babel_compile(source, **kwargs):
|
|||
presets = kwargs.get('presets')
|
||||
if not presets:
|
||||
kwargs['presets'] = ["es2015"]
|
||||
with open(BABEL_COMPILER, 'r') as babel_js:
|
||||
with open(BABEL_COMPILER, 'rb') as babel_js:
|
||||
return evaljs(
|
||||
(babel_js.read(),
|
||||
(babel_js.read().decode('utf-8'),
|
||||
'var bres, res;'
|
||||
'bres = Babel.transform(dukpy.es6code, dukpy.babel_options);',
|
||||
'res = {map: bres.map, code: bres.code};'),
|
||||
|
|
|
@ -6,9 +6,9 @@ COFFEE_COMPILER = os.path.join(os.path.dirname(__file__), 'jsmodules', 'coffeesc
|
|||
|
||||
def coffee_compile(source):
|
||||
"""Compiles the given ``source`` from CoffeeScript to JavaScript"""
|
||||
with open(COFFEE_COMPILER, 'r') as coffeescript_js:
|
||||
with open(COFFEE_COMPILER, 'rb') as coffeescript_js:
|
||||
return evaljs(
|
||||
(coffeescript_js.read(),
|
||||
(coffeescript_js.read().decode('utf-8'),
|
||||
'CoffeeScript.compile(dukpy.coffeecode)'),
|
||||
coffeecode=source
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue