Skip to content

feat(cli): adjust prisma init to write to .env instead of prisma/.env#4341

Closed
williamluke4 wants to merge 8 commits intomasterfrom
williamluke4/issue3721
Closed

feat(cli): adjust prisma init to write to .env instead of prisma/.env#4341
williamluke4 wants to merge 8 commits intomasterfrom
williamluke4/issue3721

Conversation

@williamluke4
Copy link

@williamluke4 williamluke4 commented Nov 24, 2020

  • Add tests

@williamluke4 williamluke4 force-pushed the williamluke4/issue3721 branch from 1abd55c to fcc7e2a Compare November 26, 2020 10:54
@williamluke4 williamluke4 added this to the 2.13.0 milestone Nov 26, 2020
@williamluke4 williamluke4 marked this pull request as ready for review November 26, 2020 13:54
const envFile = fs.readFileSync(envPath, { encoding: 'utf8'})
const config = dotenv.parse(envFile) // will return an object
if(Object.keys(config).includes("DATABASE_URL")){
console.warn(`${chalk.yellow('warn')} DATABASE_URL already exists in ${chalk.bold(envPath)}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be more actionable here and tell users what we would have printed and what they can do

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like:

To resolve this, we recommend moving the `DATABASE_URL` env var to the root .env

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't really need to resolve anything as this is just a warning them that they already have an ENV VAR named DATABASE_URL in their root .env. Therefore we will just not add our default DATABASE_URL to it.

@williamluke4 williamluke4 force-pushed the williamluke4/issue3721 branch from 3dadb48 to 6b89df8 Compare December 1, 2020 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants