Skip to content

Commit

Permalink
chore: parseDotenv tweak ups
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Dec 24, 2024
1 parent ce32882 commit 6eb26f5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,24 +366,23 @@ export const parseDotenv = (content: string): NodeJS.ProcessEnv => {
let k = ''
let b = ''
let q = ''
let i = false
let i = 0
const cap = () => { if (b && k) {
if (!kr.test(k)) throw new Error(`Invalid identifier: ${k}`)
e[k] = b; b = ''; k = ''
}}

for (const c of content.replace(/\r\n?/mg, '\n')) {
if (i) {
if (c === '\n') i = false
if (c === '\n') i = 0
continue
}
if (!q) {
if (c === '#') {
i = true
i = 1
continue
}
if (c === '\n') {
i = false
cap()
continue
}
Expand Down

0 comments on commit 6eb26f5

Please sign in to comment.