mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(beautify) add config, that could be read from ~/.beautify.json
This commit is contained in:
parent
5039e085d8
commit
2d9b3a542f
3 changed files with 33 additions and 2 deletions
1
HELP.md
1
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
|
||||
|
|
|
|||
18
json/beautify.json
Normal file
18
json/beautify.json
Normal file
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue