Skip to content

Commit 6d6b792

Browse files
authored
Merge pull request #523 from motdotla/windows-debug
Windows debug
2 parents 5dfa02a + 11a44c4 commit 6d6b792

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function log (message /*: string */) {
3131
const NEWLINE = '\n'
3232
const RE_INI_KEY_VAL = /^\s*([\w.-]+)\s*=\s*(.*)?\s*$/
3333
const RE_NEWLINES = /\\n/g
34-
const NEWLINES_MATCH = /\n|\r|\r\n/
34+
const NEWLINES_MATCH = /\r\n|\n|\r/
3535

3636
// Parses src into an Object
3737
function parse (src /*: string | Buffer */, options /*: ?DotenvParseOptions */) /*: DotenvParseOutput */ {

tests/test-parse.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const dotenv = require('../lib/main')
99

1010
const parsed = dotenv.parse(fs.readFileSync('tests/.env', { encoding: 'utf8' }))
1111

12-
t.plan(27)
12+
t.plan(28)
1313

1414
t.type(parsed, Object, 'should return an object')
1515

@@ -70,7 +70,13 @@ const RNPayload = dotenv.parse(Buffer.from('SERVER=localhost\r\nPASSWORD=passwor
7070
t.same(RNPayload, expectedPayload, 'can parse (\\r\\n) line endings')
7171

7272
// test debug path
73-
const logStub = sinon.stub(console, 'log')
73+
let logStub = sinon.stub(console, 'log')
7474
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)
7682
logStub.restore()

0 commit comments

Comments
 (0)