diff --git a/HELP.md b/HELP.md index a2dd46a9..eac97b62 100644 --- a/HELP.md +++ b/HELP.md @@ -146,6 +146,7 @@ Edit - Build in `emmet` (for html files) - Drag n drop (drag file from desktop to editor). - Build in `jshint` (with options in `.jshintrc` file) +- Build in `beautifier` (with options in `json/beautify.json`, could be overriden in `~/.beautify.json`) - Configurable options (could be edited in `json/edit.json`) ###Hot keys diff --git a/json/beautify.json b/json/beautify.json new file mode 100644 index 00000000..02599d7a --- /dev/null +++ b/json/beautify.json @@ -0,0 +1,18 @@ +{ + "indent_size": 4, + "indent_char": " ", + "indent_level": 0, + "indent_with_tabs": false, + "preserve_newlines": true, + "max_preserve_newlines": 10, + "jslint_happy": false, + "space_after_anon_function": false, + "brace_style": "collapse", + "keep_array_indentation": false, + "keep_function_indentation": false, + "space_before_conditional": true, + "break_chained_methods": false, + "eval_code": false, + "unescape_strings": false, + "wrap_line_length": 0 +} \ No newline at end of file diff --git a/lib/server/beautify.js b/lib/server/beautify.js index c99ab5e4..594ca23e 100644 --- a/lib/server/beautify.js +++ b/lib/server/beautify.js @@ -6,7 +6,19 @@ Util = require('../util'), tryRequire = require('./tryRequire'), - beautify = tryRequire('js-beautify'); + beautify = tryRequire('js-beautify'), + + DIR = '../../', + HOME_WIN = process.env.HOMEPATH, + HOME_UNIX = process.env.HOME, + HOME = (HOME_UNIX || HOME_WIN) + '/', + + ConfigPath = DIR + 'json/beautify.json', + ConfigHome = HOME + '.beautify.json', + + config = + tryRequire(ConfigHome) || + tryRequire(ConfigPath, {log: true}) || {}; module.exports = function(name, callback) { var EXT = ['js', 'css', 'html'], @@ -26,7 +38,7 @@ if (!error) error = Util.exec.try(function() { - result = beautify[ext](data); + result = beautify[ext](data, config); });