File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ function log (message /*: string */) {
31
31
const NEWLINE = '\n'
32
32
const RE_INI_KEY_VAL = / ^ \s * ( [ \w . - ] + ) \s * = \s * ( .* ) ? \s * $ /
33
33
const RE_NEWLINES = / \\ n / g
34
- const NEWLINES_MATCH = / \n | \r | \r \n /
34
+ const NEWLINES_MATCH = / \r \ n| \n | \r /
35
35
36
36
// Parses src into an Object
37
37
function parse ( src /*: string | Buffer */ , options /*: ?DotenvParseOptions */ ) /*: DotenvParseOutput */ {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const dotenv = require('../lib/main')
9
9
10
10
const parsed = dotenv . parse ( fs . readFileSync ( 'tests/.env' , { encoding : 'utf8' } ) )
11
11
12
- t . plan ( 27 )
12
+ t . plan ( 28 )
13
13
14
14
t . type ( parsed , Object , 'should return an object' )
15
15
@@ -70,7 +70,13 @@ const RNPayload = dotenv.parse(Buffer.from('SERVER=localhost\r\nPASSWORD=passwor
70
70
t . same ( RNPayload , expectedPayload , 'can parse (\\r\\n) line endings' )
71
71
72
72
// test debug path
73
- const logStub = sinon . stub ( console , 'log' )
73
+ let logStub = sinon . stub ( console , 'log' )
74
74
dotenv . parse ( Buffer . from ( 'what is this' ) , { debug : true } )
75
- t . ok ( logStub . called )
75
+ t . ok ( logStub . calledOnce )
76
+ logStub . restore ( )
77
+
78
+ // test that debug in windows (\r\n lines) logs just once per line
79
+ logStub = sinon . stub ( console , 'log' )
80
+ dotenv . parse ( Buffer . from ( 'HEY=there\r\n' ) , { debug : true } )
81
+ t . ok ( logStub . calledOnce )
76
82
logStub . restore ( )
You can’t perform that action at this time.
0 commit comments