feature: add db:create command (#8760)

This commit is contained in:
Harminder Virk
2024-08-26 15:04:52 +05:30
committed by GitHub
parent cd4063de74
commit 7c2cfc132a
9 changed files with 396 additions and 1 deletions

View File

@@ -51,6 +51,26 @@ export class EnvEditor {
)
}
/**
* Returns the value for an existing key from the
* ".env" file
*/
get(key: string): string | null {
const envFile = this.#files.find((file) => file.filePath.endsWith(".env"))
if (!envFile) {
return null
}
const matchingLine = envFile.contents.find((line) =>
line.startsWith(`${key}=`)
)
if (!matchingLine) {
return null
}
const [_, ...rest] = matchingLine.split("=")
return rest.join("=")
}
/**
* Set key-value pair to the dot-env files.
*