dotenv-tool
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -30,3 +30,3 @@ { | ||
}, | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"devDependencies": { | ||
@@ -33,0 +33,0 @@ "@types/node": "^20.11.26", |
@@ -159,3 +159,3 @@ import { readFile, writeFile } from 'node:fs/promises' | ||
const dataLine = this.findKey(key) | ||
if (dataLine != null) { | ||
if (dataLine !== undefined) { | ||
dataLine.data.value = newValue | ||
@@ -165,2 +165,23 @@ } | ||
deleteKey (key: string): void { | ||
let keyLineNumber: number | ||
const newContent: Line[] = [] | ||
this.contents.forEach((line) => { | ||
if (Number.isInteger(keyLineNumber)) { | ||
if (line.lineNumber > keyLineNumber) { | ||
line.lineNumber-- | ||
} | ||
newContent.push(line) | ||
} else { | ||
if (line.type === 'data' && line.data.key === key) { | ||
keyLineNumber = line.lineNumber | ||
} else { | ||
newContent.push(line) | ||
} | ||
} | ||
}) | ||
this.nextLine-- | ||
this.contents = newContent | ||
} | ||
private findKey (key: string): DataLine | undefined { | ||
@@ -167,0 +188,0 @@ const theKey = this.contents.find((line) => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39306
18
803