File tree 3 files changed +15
-7
lines changed
3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,10 @@ export class Config implements ConfigInterface {
91
91
}
92
92
93
93
private parseBuffer ( buf : Buffer ) : void {
94
- const lines = buf . toString ( ) . split ( '\n' ) ;
94
+ const lines = buf
95
+ . toString ( )
96
+ . split ( '\n' )
97
+ . filter ( ( v ) => v ) ;
95
98
const linesCount = lines . length ;
96
99
let section = '' ;
97
100
let currentLine = '' ;
@@ -123,15 +126,11 @@ export class Config implements ConfigInterface {
123
126
let shouldWrite = false ;
124
127
if ( line . includes ( Config . DEFAULT_MULTI_LINE_SEPARATOR ) ) {
125
128
currentLine += line . substring ( 0 , line . length - 1 ) . trim ( ) ;
126
- // when the last line has a "\" string
127
- if ( lineNumber + 1 === linesCount ) {
128
- shouldWrite = true ;
129
- }
130
129
} else {
131
130
currentLine += line ;
132
131
shouldWrite = true ;
133
132
}
134
- if ( shouldWrite ) {
133
+ if ( shouldWrite || lineNumber === linesCount ) {
135
134
this . write ( section , lineNumber , currentLine ) ;
136
135
currentLine = '' ;
137
136
}
Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ describe('multi-line test', () => {
23
23
expect ( config . get ( 'multi5::name' ) ) . toEqual ( 'r.sub==p.sub&&r.obj==p.obj' ) ;
24
24
} ) ;
25
25
26
+ it ( 'should config.get("multi6::name") to equal r.sub==p.sub&&r.obj==p.obj&&r.tex==p.tex' , function ( ) {
27
+ expect ( config . get ( 'multi6::name' ) ) . toEqual ( 'r.sub==p.sub&&r.obj==p.obj&&r.tex==p.tex' ) ;
28
+ } ) ;
29
+
26
30
it ( 'should config.get("mysql::mysql.master.host") to equal 10.0.0.1' , function ( ) {
27
31
expect ( config . get ( 'mysql::mysql.master.host' ) ) . toEqual ( '10.0.0.1' ) ;
28
32
} ) ;
Original file line number Diff line number Diff line change @@ -43,5 +43,10 @@ name = \
43
43
44
44
[multi5]
45
45
name = r.sub ==p.sub \
46
- &&r.obj ==p.obj\
46
+ &&r.obj ==p.obj \
47
47
\
48
+
49
+ [multi6]
50
+ name = r.sub ==p.sub \
51
+ &&r.obj ==p.obj \
52
+ &&r.tex ==p.tex
You can’t perform that action at this time.
0 commit comments