fix(cpa): proper debug logging (#10549)

Debug logs were improperly running without debug flag being passed.
This commit is contained in:
Elliot DeNolf
2025-01-13 14:14:46 -05:00
committed by GitHub
parent 6757f7d459
commit 9004205b84

View File

@@ -78,6 +78,8 @@ export async function manageEnvFiles(args: {
}): Promise<void> {
const { cliArgs, databaseType, databaseUri, payloadSecret, projectDir, template } = args
const debugFlag = cliArgs['--debug']
if (cliArgs['--dry-run']) {
debug(`DRY RUN: Environment files managed`)
return
@@ -100,7 +102,10 @@ export async function manageEnvFiles(args: {
updatedExampleContents = updateEnvExampleVariables(envExampleContents, databaseType)
await fs.writeFile(envExamplePath, updatedExampleContents.trimEnd() + '\n')
debug(`.env.example file successfully updated`)
if (debugFlag) {
debug(`.env.example file successfully updated`)
}
} else {
updatedExampleContents = `# Added by Payload\nDATABASE_URI=your-connection-string-here\nPAYLOAD_SECRET=YOUR_SECRET_HERE\n`
await fs.writeFile(envExamplePath, updatedExampleContents.trimEnd() + '\n')
@@ -116,7 +121,9 @@ export async function manageEnvFiles(args: {
)
await fs.writeFile(envPath, `# Added by Payload\n${envContent.trimEnd()}\n`)
debug(`.env file successfully created or updated`)
if (debugFlag) {
debug(`.env file successfully created or updated`)
}
} catch (err: unknown) {
error('Unable to manage environment files')
if (err instanceof Error) {