1
1
var jsbeautify = require ( 'js-beautify' ) . js_beautify ;
2
- var merge = require ( 'deepmerge' ) ;
2
+ var deepmerge = require ( 'deepmerge' ) ;
3
3
var through = require ( 'through2' ) ;
4
4
var PluginError = require ( 'plugin-error' ) ;
5
5
var detectIndent = require ( 'detect-indent' ) ;
6
6
7
- module . exports = function ( editor , jsbeautifyOptions , mergeOptions ) {
8
-
7
+ module . exports = function ( editor , jsbeautifyOptions , deepmergeOptions ) {
9
8
10
9
/*
11
- * extras merge options
12
- * this options is only pass to deepmerge
10
+ * deepmerge options
13
11
*/
14
- mergeOptions = mergeOptions || { } ;
12
+ deepmergeOptions = deepmergeOptions || { } ;
15
13
16
14
/*
17
15
* create 'editBy' function from 'editor'
@@ -23,7 +21,7 @@ module.exports = function (editor, jsbeautifyOptions, mergeOptions) {
23
21
}
24
22
else if ( typeof editor === 'object' ) {
25
23
// edit JSON object by merging with user specific object
26
- editBy = function ( json ) { return merge ( json , editor , mergeOptions ) ; } ;
24
+ editBy = function ( json ) { return deepmerge ( json , editor , deepmergeOptions ) ; } ;
27
25
}
28
26
else if ( typeof editor === 'undefined' ) {
29
27
throw new PluginError ( 'gulp-json-editor' , 'missing "editor" option' ) ;
@@ -59,7 +57,7 @@ module.exports = function (editor, jsbeautifyOptions, mergeOptions) {
59
57
var indent = detectIndent ( file . contents . toString ( 'utf8' ) ) ;
60
58
61
59
// beautify options for this particular file
62
- var beautifyOptions = merge ( { } , jsbeautifyOptions ) ; // make copy
60
+ var beautifyOptions = deepmerge ( { } , jsbeautifyOptions ) ; // make copy
63
61
beautifyOptions . indent_size = beautifyOptions . indent_size || indent . amount || 2 ;
64
62
beautifyOptions . indent_char = beautifyOptions . indent_char || ( indent . type === 'tab' ? '\t' : ' ' ) ;
65
63
beautifyOptions . beautify = ! ( 'beautify' in beautifyOptions && ! beautifyOptions . beautify ) ;
0 commit comments