Fixes #9. Nested options in .jsbeautifyrc are properly handled.
This commit is contained in:
parent
b9d7869a66
commit
54e61a816f
|
@ -7,5 +7,6 @@
|
|||
"preserve_newlines": true,
|
||||
"max_preserve_newlines": 2,
|
||||
"jslint_happy": true,
|
||||
"indent_handlebars": true
|
||||
"indent_handlebars": true,
|
||||
"object": {}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>Test Page</title>
|
||||
<title>Test Page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Hello</h1>
|
||||
<p>
|
||||
World!
|
||||
</p>
|
||||
<h1>Hello</h1>
|
||||
<p>
|
||||
World!
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -159,6 +159,10 @@ function beautify() {
|
|||
var softTabs = editor.softTabs;
|
||||
var tabLength = editor.getTabLength();
|
||||
|
||||
// Supported unique configuration keys
|
||||
// Used for detecting nested configurations in .jsbeautifyrc
|
||||
var languages = ['js', 'html', 'css', 'sql'];
|
||||
|
||||
var defaultOptions = {
|
||||
'indent_size': softTabs ? tabLength : 1,
|
||||
'indent_char': softTabs ? ' ' : '\t',
|
||||
|
@ -182,7 +186,7 @@ function beautify() {
|
|||
encoding: 'utf8'
|
||||
})));
|
||||
} catch (e) {
|
||||
console.log('Failed parsing config JSON at '+configPath);
|
||||
console.log('Failed parsing config JSON at ' + configPath);
|
||||
externalOptions = {};
|
||||
}
|
||||
} else {
|
||||
|
@ -218,7 +222,8 @@ function beautify() {
|
|||
|
||||
// Check to see if config file uses nested object format to split up js/css/html options
|
||||
for (key in currOptions) {
|
||||
if (typeof currOptions[key] === 'object') {
|
||||
if (_.indexOf(languages, key) >= 0 && // Check if is supported language
|
||||
typeof currOptions[key] === 'object') { // Check if nested object (more options in value)
|
||||
containsNested = true;
|
||||
break; // Found, break out of loop, no need to continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue