Skip to content

Commit 9004205

Browse files
authored
fix(cpa): proper debug logging (#10549)
Debug logs were improperly running without debug flag being passed.
1 parent 6757f7d commit 9004205

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/create-payload-app/src/lib/manage-env-files.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export async function manageEnvFiles(args: {
7878
}): Promise<void> {
7979
const { cliArgs, databaseType, databaseUri, payloadSecret, projectDir, template } = args
8080

81+
const debugFlag = cliArgs['--debug']
82+
8183
if (cliArgs['--dry-run']) {
8284
debug(`DRY RUN: Environment files managed`)
8385
return
@@ -100,7 +102,10 @@ export async function manageEnvFiles(args: {
100102
updatedExampleContents = updateEnvExampleVariables(envExampleContents, databaseType)
101103

102104
await fs.writeFile(envExamplePath, updatedExampleContents.trimEnd() + '\n')
103-
debug(`.env.example file successfully updated`)
105+
106+
if (debugFlag) {
107+
debug(`.env.example file successfully updated`)
108+
}
104109
} else {
105110
updatedExampleContents = `# Added by Payload\nDATABASE_URI=your-connection-string-here\nPAYLOAD_SECRET=YOUR_SECRET_HERE\n`
106111
await fs.writeFile(envExamplePath, updatedExampleContents.trimEnd() + '\n')
@@ -116,7 +121,9 @@ export async function manageEnvFiles(args: {
116121
)
117122
await fs.writeFile(envPath, `# Added by Payload\n${envContent.trimEnd()}\n`)
118123

119-
debug(`.env file successfully created or updated`)
124+
if (debugFlag) {
125+
debug(`.env file successfully created or updated`)
126+
}
120127
} catch (err: unknown) {
121128
error('Unable to manage environment files')
122129
if (err instanceof Error) {

0 commit comments

Comments
 (0)