MCPcopy
hub / github.com/prisma/prisma / isAlreadyLinked

Function isAlreadyLinked

packages/cli/src/postgres/link/local-setup.ts:80–89  ·  view source on GitHub ↗
(projectDir: string)

Source from the content-addressed store, hash-verified

78
79/** Checks if `DATABASE_URL` in the project's `.env` already points to a Prisma Postgres instance. */
80export function isAlreadyLinked(projectDir: string): boolean {
81 const envPath = path.join(projectDir, '.env')
82
83 if (!fs.existsSync(envPath)) {
84 return false
85 }
86
87 const parsed = dotenv.parse(fs.readFileSync(envPath, 'utf-8'))
88 return PRISMA_POSTGRES_URL_PATTERN.test(parsed.DATABASE_URL ?? '')
89}
90
91/** Writes connection strings to `.env` and reports the `.gitignore` status. */
92export function writeLocalFiles(projectDir: string, connection: ConnectionResult): WriteLocalFilesResult {

Callers 4

parseMethod · 0.90
linkMethod · 0.90
runMethod · 0.90

Calls 1

parseMethod · 0.65

Tested by

no test coverage detected