Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML Support 🙌 #133

Open
Pytal opened this issue May 1, 2020 · 4 comments
Open

YAML Support 🙌 #133

Pytal opened this issue May 1, 2020 · 4 comments

Comments

@Pytal
Copy link

Pytal commented May 1, 2020

It would be great if YAML support could be added for .env.yaml and .env-cmdrc.yaml, would this be possible?

@Pytal Pytal changed the title YAML Support YAML Support 🙌 May 1, 2020
@toddbluhm
Copy link
Owner

This is a cool idea. Interested in opening a PR?

@KilianKilmister
Copy link

I just took a look at the loader and it would be very easy to implement.
i'd also suggest you don't use require to get the file, but use a native dynamic import to load .js/.cjs and use a parser wrapped inside a helper-function otherwhise.

This would have a couple of benefits:

  • the loader itself would be vanilla JS/ES
  • the code would be more straigth-forward
  • any kind of object-notation can be supported by simply adding a case for it's extension that points to its parser

the change should not amount to more than 30 lines and performance and stability can only increase

i'll have a look at it

btw i love that you include esm-loading, and what are your thoughts on JSON5 support?

@johantiden
Copy link

johantiden commented Apr 7, 2022

This would be great, especially when working with other libraries that force use of yaml (e.g. gcloud functions).
I used this ugly sed-workaround to operate both:

  "scripts": {
    "generate-env": "cat .env.yaml | sed \"s#: #=#g\" > build/.env",
    "start": "yarn generate-env && env-cmd -f build/.env YOUR_CODE_HERE",
    "deploy": "gcloud functions deploy --env-vars-file .env.yaml ..."
  }

@aliwatters
Copy link

our workaround.

yq -o=json eval .env.yaml > .env.json https://github.com/mikefarah/yq

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

No branches or pull requests

5 participants