Created
November 28, 2016 09:16
-
-
Save beginor/633be78cc4ab6630c7c37f30c3671f8b to your computer and use it in GitHub Desktop.
parse and beautify javascript with uglify-js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as uglifyJs from 'uglify-js'; | |
| import * as path from 'path'; | |
| import * as fs from 'fs'; | |
| var p = path.resolve(__dirname, 'jsapi/esri/nls/zh-cn/jsapi.js'); | |
| console.log(p); | |
| fs.readFile(p, { encoding: 'utf-8' }, (ex, data) => { | |
| //console.log(data); | |
| var result = uglifyJs.parse(data, {}); | |
| var js = result.print_to_string({ | |
| beautify: true, | |
| quote_keys: false, | |
| space_colon: true, | |
| bracketize: true, | |
| semicolons: true, | |
| comments: true, | |
| ascii_only: false, | |
| width: 80 | |
| }); | |
| console.log(js); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment