MCPcopy
hub / github.com/prisma/prisma / checkGitignore

Function checkGitignore

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

Source from the content-addressed store, hash-verified

52
53/** Returns whether `.gitignore` in `projectDir` already ignores `.env` files. */
54export function checkGitignore(projectDir: string): GitignoreStatus {
55 const gitignorePath = path.join(projectDir, '.gitignore')
56
57 if (!fs.existsSync(gitignorePath)) {
58 return 'no-file'
59 }
60
61 const content = fs.readFileSync(gitignorePath, 'utf-8')
62 const lines = content.split('\n').map((l) => l.trim())
63
64 const hasEnvEntry = lines.some((line) => {
65 const normalized = line.startsWith('/') ? line.slice(1) : line
66 return normalized === '.env' || normalized === '.env*'
67 })
68 return hasEnvEntry ? 'ok' : 'missing-entry'
69}
70
71/** Combined result of writing `.env` and checking `.gitignore`. */
72export interface WriteLocalFilesResult {

Callers 2

writeLocalFilesFunction · 0.85

Calls 1

sliceMethod · 0.45

Tested by

no test coverage detected